3
Answers

Collection was modified; enumeration operation might not exe

kalu singh rao

kalu singh rao

10y
5.6k
1
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)