How to return the value of AUTO INCREMENT column in SQLite with VB6
Does SQLite support SCOPE_IDENTITY?
Check out the FAQ. The sqlite3_last_insert_rowid() function will do it. Careful of triggers though
Not tested, but you should be able to send both statements in one call. It's been a while since I wrote any VB6. Also this is not SQL injection safe.
Dim oRs as Recordsetdim sSql as StringsSql = "INSERT INTO EventType (EventTypeName) VALUES ('blah'); SELECT last_insert_rowid() FROM EventType"oRs.Open sSql oConn
Run this query inside of your code:
SELECT SEQ from sqlite_sequence WHERE name='tablename'
I don't use VB, so I don't know the interface you're using with your database, but, as bendewey said, there is a function in the c API called sqlite3_last_insert_rowid()
that will return the primary integer key for the last inserted row, so you could look for a similar function in your interface.
If that doesn't work, you can use the SQLite-specific query:
SELECT last_insert_rowid()