A .NET wrapper to the SQLite database

SQLiteClient.LastInsertID Method 

Returns the last insert id for this database

[Visual Basic]
Public Function LastInsertID() As Integer
[C#]
public int LastInsertID();

Return Value

Integer of the id

Remarks

Every row of an SQLite table has a unique integer key. If the table has a column labeled INTEGER PRIMARY KEY, then that column serves as the key. If there is no INTEGER PRIMARY KEY column then the key is a unique integer. The key for a row can be accessed in a SELECT statement or used in a WHERE or ORDER BY clause using any of the names "ROWID", "OID", or "_ROWID_".

When you do an insert into a table that does not have an INTEGER PRIMARY KEY column, or if the table does have an INTEGER PRIMARY KEY but the value for that column is not specified in the VALUES clause of the insert, then the key is automatically generated. You can find the value of the key for the most recent INSERT statement using the this method.

See Also

SQLiteClient Class | SQLite.NET Namespace