MySQL Forums
Forum List  »  Microsoft Access

how to get id of last inserted row
Posted by: richard.arnold
Date: December 08, 2004 06:50AM

Hi there, overall migrating from access to mysql surprisingly easy, but there's one thing I can't get fixed. I've been trying to get this right for a couple of hours now, google doesn't help me too much, and i should conclude that i can't get it working...
Here's the thing:

the connection string:
"Driver={Mysql ODBC 3.51 Driver}; Server=localhost; Database=dbname; UID=login; PWD=pass; Option=3"

the code:
set rsUpdate = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * from table WHERE 0=1"
rsUpdate.Open sql, dbc, adOpenKeyset, adLockPessimistic, adCmdText
rsUpdate.Addnew
val1 = "string"
val2 = "string"
etc. etc...
rsUpdate.Update
id = rsUpdate("id")

the problem:
id is empty, while using Access it contains the last inserted (auto incremented) id.
I read about LAST_INSERT_ID(), but how do I use this without opening a new recordset, and are there any other ways to get the value?

Options: ReplyQuote


Subject
Views
Written By
Posted
how to get id of last inserted row
14933
December 08, 2004 06:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.