This topic is locked

SELECT LAST_INSERT_ID() in xx_add.asp

4/13/2005 2:50:04 PM
ASPRunnerPro General questions
Pfeiffer author

Hello Admin,
in MySQL there is a function to get the last autonumber id with the

function LAST_INSERT_ID() after an add operation.
With the SQL-Select Statement

SELECT LAST_INSERT_ID() you can get this value.
Can you please show, how and where to put this function in the

generated xx_add.asp File for MYSQL as an example ?
I need the new autonumber ID for other functions immediately after the new record is saved.
Thank you.

Uwe Pfeiffer

Admin 4/14/2005

Hi,
you can modify xx_add.asp code:

rs.Update

rs.Close
Set rs1 = Server.CreateObject("ADODB.Recordset")

rs1.Open "SELECT LAST_INSERT_ID()", dbConnection
message="<div class=message><<< " & "Record was added,ID: " & rs1(0)& " >>></div>"
rs1.Close

hanb 11/6/2007

Hi,

you can modify xx_add.asp code:



How would I use the last_insert_id in the afterAdd event in ASPRunner 5.1

I need to generate an order id containing the id number, like "clinic" & dict(lastid)

and then do an update of the last record.

Saw examples but they seem to work only in previous versions.

Han

Admin 11/6/2007

Han,
the same example will work in ASPRunnerPro 5.1:
Set rs1 = Server.CreateObject("ADODB.Recordset")

rs1.Open "SELECT LAST_INSERT_ID()", dbConnection

hanb 11/17/2007

Han,

the same example will work in ASPRunnerPro 5.1:
Set rs1 = Server.CreateObject("ADODB.Recordset")

rs1.Open "SELECT LAST_INSERT_ID()", dbConnection


I suppose I now have to save the last insert value somewhere to use it in a next add record.

How do I code the update table 'registratie' field 'Registratienr'

and how do I read it in the next add.

hanb 11/17/2007



I suppose I now have to save the last insert value somewhere to use it in a next add record.

How do I code the update table 'registratie' field 'Registratienr'

and how do I read it in the next add.


I am thinking of the code in the event coding after add and before add, not normal ASP programs

Admin 11/19/2007

Han,
you need to clarify what you like to do with this value.