SQLite.NET output parameter

陌路散爱 提交于 2020-05-17 06:38:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!