Hi,

I am using both VB6 and C/C++ to interface to a SQLITE3 database. If I
execute a command that inserts a new record, such as:

      'Set the various columns
      strUpdate = ", dataCol2, dataCol3, ..., dataColN"

      'Create the SQL command.
      strSQLCommand = "INSERT INTO " + strDBTable + " VALUES (null" +
strUpdate + ");"

      'DATABASE: Execute the query.
      bSuccess = Me.DBConnection.Execute(strSQLCommand)

I realize that I can issue a SELECT statement immediately afterwards, such
as:

SELECT IDPrimary FROM myTable ORDER BY IDPrimary DESC

and that with some data comparison can yield me the primary key of the newly
inserted record, but this method is slow, not very elegant, and if multiple
people use the database at the same time, the result may not be accurate.

QUESTION: How do I get the primary key of the newly inserted record? Is
there some sort of handle that comes back to the newly inserted record?

For whatever it is worth, I am using the dhRichclient library from
thecommon.net as a VB6 wrapper, but that is meaningless, as I can use the
sqlite library directly with C++ and I would still have the same question or
write my own wrapper.

I did a search on Google but could not find anything. :-(

Thanks in advance,

Sarah.
-- 
View this message in context: 
http://www.nabble.com/How-to-get-PRIMARY-KEY-of-newly-INSERT-INTO-record-tp23083322p23083322.html
Sent from the SQLite mailing list archive at Nabble.com.

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

Reply via email to