Simple question:
When I call SqlDataAdapter.Fill(DataGridView.DataSource)
the second time after initially creating first Data it does not update the contain
From MSDN:
You can use the
Fill
method multiple times on the sameDataTable
. If a primary key exists, incoming rows are merged with matching rows that already exist. If no primary key exists, incoming rows are appended to the DataTable.
So either define a primary key or clear the table first.
Dim table = CType(DataGridView.DataSource, DataTable)
table.Clear()
' fill ...
To define primary key(s) manually read this. To let it create automatically if they are defined in the database you need to set the MissingSchemaAction
to AddWithKey
:
' ...
dataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
' fill ...