SprintFlunky
Programmer
Question about the delete functions in a dataview. I am looping through a dataview to validate parent/child relationships. When the parent is not found, I copy the row to a new error table, then delete the row from the dataview.
For Each drv As DataRowView In dvLocMstr
If … "invalid" then
dtRpt.ImportRow(drv.Row)
drv.Delete()
End if
Next
This works great, until I get to the last few rows the for each loop. I get a “can’t find dv row” error. I suspect it’s because I have changed the “row count” by performing the delete, but I don’t accept the changes until I’m out of the loop.
How do I “delete” the row in the dataview without affecting the “for each” loop?
Thanks for any help - this is driving me nuts.
For Each drv As DataRowView In dvLocMstr
If … "invalid" then
dtRpt.ImportRow(drv.Row)
drv.Delete()
End if
Next
This works great, until I get to the last few rows the for each loop. I get a “can’t find dv row” error. I suspect it’s because I have changed the “row count” by performing the delete, but I don’t accept the changes until I’m out of the loop.
How do I “delete” the row in the dataview without affecting the “for each” loop?
Thanks for any help - this is driving me nuts.