On 2012-03-08 11:07, Joe D wrote:
On 2012-03-06 15:20, Pawl wrote:

Hi,

I don't know how to make this EASY thing (for me side) I found only this,
but they said it is solverd, but it isn;t
http://stackoverflow.com/questions/3828098/solved-how-to-return-autoincrement-value-in-insert-query-in-sqlite


I don;t know what I get exception Not supported when I tried to setup
ParameterDirection another then input!

I add this "sqa.InsertCommand.UpdatedRowSource =
UpdateRowSource.FirstReturnedRecord;" before. But without any result!

Try this.

SQLiteCommand command = new SQLiteCommand("INSERT INTO TABLE (FIELD1,
FIELD2) VALUES (:FIELD1, :FIELD2); SELECT LAST_INSERT_ROWID();");

... append parameters ...

int nextValue = command.ExecuteScalar();

Or if you're looking for a specific column and not the ROWID, try this:

SQLiteCommand command = new SQLiteCommand("INSERT INTO TABLE (FIELD1, FIELD2) VALUES (:FIELD1, :FIELD2); SELECT FIELD1 FROM TABLE WHERE ROWID = LAST_INSERT_ROWID();");

... append parameters ...

int nextValue = command.ExecuteScalar();

Never tried that, but it looks like it should work...

Joe D
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to