How to delete items from a DataTable during an enumeration


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm trying to enumerate all the rows in a DataTable and if a certain condition is met, delete the current row. .NET doesn't like this:





Dim myTable As DataTable

'...fill table, two columns a string and an integer

For Each myRow As DataRow In myTable.Rows

If myRow.Item(1) = 34 Then

myTable.Delete(myRow)

End If

Next





It bombs when the Next statement hits. Is there another way to do this?

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search