问题
I have a object that contains data from a DB. The object has a ID, which in the DB is auto increment field. When creating an object i dont know his ID, until i insert a new record to the DB. Then i want to get back the auto generated value of ID field.
I tried to do so by adding a Output parameter, but SQLite.NET throws a NotSupportedException
when i try to set the Direction
to ParameterDirection.Output
.
What can i do? The other fields except ID are not unique.
A other option is to auto increment manually, in the program, but it seems to be a bit complicated to implement.
Thanks a lot.
回答1:
SELECT last_insert_rowid();
This will get the last inserted ROWID. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
来源:https://stackoverflow.com/questions/11179125/sqlite-net-output-parameter