RowNotInTableException - VB.NET 2.0
-
I am having an issue that seems to be specific to a single input source. I select a group of rows from a table and based on some matching determine that they are duplicates for my purpose. I fill an arraylist with the actual datarows and then after I am finished with all of the logic of determining the duplicates, I remove them like this.
For Each duplicateRowToRemove As DataRow In rowsToRemove duplicateTable.Rows.Remove(duplicateRowToRemove) End If Next
I receive the RowNotInTableException or some version of an IndexOutOfRange exception everytime. I have tried adding a primary key by just incrementing a counter and inserting it in the "ID" column, I have tried to check whether a row exists in the arraylist before adding it, I have tried to check to see if the row exists before removing it and nothing works. What am I missing here? This code has been in place for 4 months with no issues until today's input source (file) came in. FYI - I can still run previous files but this one keeps causing the process to exception out.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
-
I am having an issue that seems to be specific to a single input source. I select a group of rows from a table and based on some matching determine that they are duplicates for my purpose. I fill an arraylist with the actual datarows and then after I am finished with all of the logic of determining the duplicates, I remove them like this.
For Each duplicateRowToRemove As DataRow In rowsToRemove duplicateTable.Rows.Remove(duplicateRowToRemove) End If Next
I receive the RowNotInTableException or some version of an IndexOutOfRange exception everytime. I have tried adding a primary key by just incrementing a counter and inserting it in the "ID" column, I have tried to check whether a row exists in the arraylist before adding it, I have tried to check to see if the row exists before removing it and nothing works. What am I missing here? This code has been in place for 4 months with no issues until today's input source (file) came in. FYI - I can still run previous files but this one keeps causing the process to exception out.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
You should not attempt to remove items from a collection when performing a
For Each
through the same collection. Use aFor
loop to traverse the collection in reverse order, removing the items as you go.Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush