getting autoinc value

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
eugenem
Posts: 8
Joined: Fri 04 Feb 2011 20:48

getting autoinc value

Post by eugenem » Fri 18 Feb 2011 13:08

Is there any reasonable way to automatically get autoinc values after inserting into table?

ds2.Groups.AddGroupsRow(...);
ds2.Groups.Update();

this reloads table completely and gets new ids obviously, but it doesn't feel good
ds2.Groups.Clear();
ds2.Groups.Fill();

there is autoinc ID field in the table

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 21 Feb 2011 18:14

You are right, the mentioned code doesn't look good. But SQLite engine doesn't support SQL for updating result set with the values generated in the database for the autoincrement columns. So, your code can be solution.

The SQLiteCommand class includes the InsertID property which returns the rowid of the most recent successful INSERT into the database. This is just for information (it doesn't help in this situation).

Post Reply