StrataFrame Forum
Back
Login
Login
Home
»
.NET Forums
»
General .NET Discussion
»
How to delete items from a DataTable during an enumeration
How to delete items from a DataTable during an enumeration
Post Reply
Like
0
How to delete items from a DataTable during an enumeration
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Greg McGuffey
Greg McGuffey
posted 17 Years Ago
ANSWER
Topic Details
Share Topic
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?
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
How to delete items from a DataTable during an enumeration
Greg McGuffey
-
17 Years Ago
It is because you are changing the contents of the value being...
Trent L. Taylor
-
17 Years Ago
Thanks for the help. While implementing what you suggestion, I...
Greg McGuffey
-
17 Years Ago
This has nothing to do with data tables, but rather any type of...
Trent L. Taylor
-
17 Years Ago
Got it. I think the DataRow.Delete() works because it doesn't remove...
Greg McGuffey
-
17 Years Ago
Good. :)
Trent L. Taylor
-
17 Years Ago
Post Reply
Like
0
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search