M
MattB
I'm using vb.net, but if you only have a c# answer, feel free to offer it!.
Anyway, I have a DataTable and a DataView which is a subset I have ID'd
to be deleted from that DataTable. I tried looping through the DataView
and deleting rows like this:
Dim dvAuto As New DataView
dvAuto.Table = dtCart
dvAuto.RowFilter = "AutoAdd = True"
If dvAuto.Count > 0 Then
Dim dr As DataRow
For Each dr In dvAuto.Table.Rows
dr.Delete()
Next
End If
But obviously it didn't work. I suspected modifying a collection while
looping through it would be a no-no and I was right (but tried anyway).
Without being able to issues a SQL delete like:
delete from dtCart where AutoAdd = True
I'm just not sure how to do this. How is this typically done? Thanks!
Matt
Anyway, I have a DataTable and a DataView which is a subset I have ID'd
to be deleted from that DataTable. I tried looping through the DataView
and deleting rows like this:
Dim dvAuto As New DataView
dvAuto.Table = dtCart
dvAuto.RowFilter = "AutoAdd = True"
If dvAuto.Count > 0 Then
Dim dr As DataRow
For Each dr In dvAuto.Table.Rows
dr.Delete()
Next
End If
But obviously it didn't work. I suspected modifying a collection while
looping through it would be a no-no and I was right (but tried anyway).
Without being able to issues a SQL delete like:
delete from dtCart where AutoAdd = True
I'm just not sure how to do this. How is this typically done? Thanks!
Matt