'Collection was modified; enumeration operation may not execute'
One more thing to be sure that the iterating will be performed succesfully is to iterate through returned by DataTable.Select() rows (not DataTable.Rows).
For Each row As DataRow In dt.Select()
If (bool_statement) Then
row.Delete()
End If
Next
dt.AcceptChanges
If adapter is used changes can be commited by Update method. All rows with DataRow.RowState of 'Deleted' will be deleted.
thanks you! very useful
ReplyDeleteWas stuck on this.
ReplyDeleteThis was very helpful thank you! :)
Just 1 thing, row.Deleted() should be row.Delete()
Thanks :)