As the
SQLite documentation[
^] says:
The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function.
Which means in essence that it only works within the same Connection (And I'd only use it inside the same Command).
Once you open a new connection, you will always get 0 until you perform an insert on that connection.
Me? I'd do this:
INSERT INTO MyTable (Column1) VALUES(6); SELECT Last_Insert_Rowid();
as my SQLiteCommand...