I've got a DataTable that I need to delete some rows from; I'm trying the following code but getting some unexpected results
My expectation is that the DatabaseAuxiliary_Table_Query would return all of the results in DatabaseAuxiliary_Table with a given strAutoCADFile.
I would then iterate through these rows and delete them one by one.
What's happening is that when I delete the 1st row, I can see by clicking the 'magnifying glass' to view that DatabaseAuxiliary_Table and see that several rows (that previously had the strAutoCADFile value) no longer have it.
1st question is why would that be happening?
My 2nd issue is that when it runs again for the 2ND value of strAutoCADFile, it sometimes returns a 'DeletedRowInaccessibleException' exception. I believe that this is happening because it's trying to delete a row that's already been deleted. It's not clear to me why this would be the case since I'm only executing this code one time for each strAutoCADFile.
Thoughts?
Many thanks in advance!
VB.NET:
Dim DatabaseAuxiliary_Table_Query = From ADG_Auxiliary_Record In DatabaseAuxiliary_Table.AsEnumerable() Select ADG_Auxiliary_Record _
Where (ADG_Auxiliary_Record.Field(Of Object)(DrawingFileName_Auxiliary_Field) = strAutoCADFile)
'Delete ALL Auxiliary Blocks CURRENTLY in Auxiliary Table for THIS Drawing
For Each ADG_Auxiliary_Record In DatabaseAuxiliary_Table_Query
ADG_Auxiliary_Record.Delete()
Next
My expectation is that the DatabaseAuxiliary_Table_Query would return all of the results in DatabaseAuxiliary_Table with a given strAutoCADFile.
I would then iterate through these rows and delete them one by one.
What's happening is that when I delete the 1st row, I can see by clicking the 'magnifying glass' to view that DatabaseAuxiliary_Table and see that several rows (that previously had the strAutoCADFile value) no longer have it.
1st question is why would that be happening?
My 2nd issue is that when it runs again for the 2ND value of strAutoCADFile, it sometimes returns a 'DeletedRowInaccessibleException' exception. I believe that this is happening because it's trying to delete a row that's already been deleted. It's not clear to me why this would be the case since I'm only executing this code one time for each strAutoCADFile.
Thoughts?
Many thanks in advance!