Inserting AutoIncrement Primary Keys

Scenario Inserting Rows into a table that uses an AutoIncrement column as the Primary Key

Issue DataSet not updated with Primary Key from database


1. Select back the ID

2. Insert it into the row

3. Register for UpdatedEvent to prevent AcceptChanges from being called if you want to merge results back to original DataSet

4. Update parents before children

5. Set UpdateRule=Cascade

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.