2 messages in com.mysql.lists.win32LAST_INSERT_ID() in ASP pages.
FromSent OnAttachments
Glenn F. Henriksen01 Dec 2000 16:44 
Carsten Gehling01 Dec 2000 16:46 
Subject:LAST_INSERT_ID() in ASP pages.
From:Glenn F. Henriksen (gle@itl.no)
Date:12/01/2000 04:44:21 PM
List:com.mysql.lists.win32

Hello.

I'm evaluating mySQL for a client in connection to a project which requires an SQL server. I felt that mySQL fitted the customers requirements (I have never used it before) and started looking into it.

I have run into a problem that for the moment makes it impossible to use mySQL. There must be some way around this:

I have an ASP page that is inserting a record in a table with ADO. Immediatly afterwards it's inserting some other records in another table. These two tables have a many to many relationship (devided in a third table through normalization).

Therefore I need to take the LAST_INSERT_ID() value of the AUTO_INCREMENT id field and use later. The problem is that any statement with "select LAST_INSERT_ID()" returns no records.

I use myODBC and connect like this: set oConnection= createobject("adodb.connection") oConnection.Open("DSN=DNSName;uid=user1;pwd=pass1") oConnection.Execute("insert ( la, bla1 ) VALUES (213, 'sdlkfj')

RecordSet = oConnection.Execute("select LAST_INSERT_ID()")

Now I have an empty recordset... What am I doing wrong? I get an error message from the SQL server if I have them both in the same statment seperated with ;

The record is inserted too.

If I try the statements in mysql it works fine.

Can anyone help please? If I don't get this functionality then I cannot use mySQL. Is there another way to do it?

Thank you.

Regards, Glenn Henriksen