get last added auto-id from mysql

Results 1 to 3 of 3

Thread: get last added auto-id from mysql

  1. #1
    Join Date
    Dec 1969

    Default get last added auto-id from mysql

    Hi there, overall migrating from access to mysql surprisingly easy, but there&#039;s one thing I can&#039;t get fixed. I&#039;ve been trying to get this right for a couple of hours now, google doesn&#039;t help me too much, and i should conclude that i can&#039;t get it working... <BR>Here&#039;s the thing: <BR><BR>the connection string: <BR>"Driver={Mysql ODBC 3.51 Driver}; Server=localhost; Database=dbname; UID=login; PWD=pass; Option=3" <BR><BR>the code: <BR>set rsUpdate = Server.CreateObject("ADODB.Recordset") <BR>sql = "SELECT * from table WHERE 0=1" <BR>rsUpdate.Open sql, dbc, adOpenKeyset, adLockPessimistic, adCmdText <BR>rsUpdate.Addnew <BR>val1 = "string" <BR>val2 = "string" <BR>etc. etc... <BR>rsUpdate.Update <BR>id = rsUpdate("id") <BR><BR>the problem: <BR>id is empty, while using Access it contains the last inserted (auto incremented) id. <BR>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?

  2. #2
    Join Date
    Dec 1969

    Default Open a new recordset. (eop)


  3. #3
    Join Date
    Dec 1969

    Default And for what it's worth...

    ...whether your code works or not depends upon the driver. And patently that version of the MYSQL driver doesn&#039;t support this.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts