I see a similar problem, but I can’t use .Clear because the DataTable bound to a user interface list, and .Clear followed by .Fill causes the list to lose the current user selection. So I implemented a (ugly) workaround that basically consists of
- changing a field in a DataTable to a value that I know this field will never be
- running
.Fill - delete all rows containing this value
In other words:
For Each drow As DataRow In dset.Tables(0).Rows drow.Item("myField") = -1 Next myDataAdapter.Fill(dset) Dim drowsRemove = (From drow In dset.Tables(0).AsEnumerable() _ Where drow.Field(Of Integer)("myField") = -1).ToList() For Each drow In drowsRemove dset.Tables(0).Rows.Remove(drow) Next
Any suggestions for more elegant solutions are welcome.
source share