Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. RowNotInTableException - VB.NET 2.0

RowNotInTableException - VB.NET 2.0

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marcus J Smith
    wrote on last edited by
    #1

    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)

    P 1 Reply Last reply
    0
    • M Marcus J Smith

      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)

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      You should not attempt to remove items from a collection when performing a For Each through the same collection. Use a For 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups