...

View Full Version : Get id of last inserted row



maxpouliot
04-10-2006, 05:33 PM
Hi,

i'm using asp with access and i need to get the id of the following code

SQL="INSERT INTO tAteliers (nom,dateA, heure, duree, endroit, max, restantes, formateurs) VALUES ('" & nom & "','" & dateA & "', '" & heureA & "', '" & duree2 & "', '" & endroitA & "', " & maxA & ", " & maxA & ",'" & formateurs &"')"

Conn.Execute(SQL)

What's the more efficient way to get the id? In php i use mysql_insert_id, but is there something equivalent in asp with access?

Archangel
04-10-2006, 08:14 PM
Couple things...first off...if you want to return the ID then you have to convert this to use a RecordSet intstead of just executing a SQL Statement.

Secondly, what you're looking for is @@identity (Returns the ID of the last inserted row)

So at the end of you statement you could try adding something like

SELECT @@identity AS tAteliers_ID



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum