kalu singh rao

kalu singh rao

  • 275
  • 6.4k
  • 109.4k

Collection was modified; enumeration operation might not exe

Nov 12 2014 12:41 AM
I am working on in vb.net . Here i want to remove row of datatable using rowid. All is working fine but after remove row from datatable then i got a error message is Collection was modified; enumeration operation might not execute. I am using following code for delete row from datatable.
 
 vb.net code:-
 
Dim dr As DataRow
For Each dr In dt.Rows
If dr("RowID").ToString() = dt.Rows(0)("RowID").ToString() Then
dt.Rows.Remove(dr)
End If
Next 

Answers (3)