This topic is locked

Display Primary Key Identifier after Add

3/9/2005 8:31:24 PM
ASPRunnerPro General questions
D
ducmis author

I have a PID (autonumber) as an identifier for my table. I would like the add page return the PID after adding a record by displaying
You have successfully added record # XXX....
could anyone help

Sergey Kornilov admin 3/10/2005

Hi,
you can modify this part of the..._add.asp page:

message="<div class=message><<< Record was added >>></div>"

set rsid = Server.CreateObject("ADODB.Recordset")

rsid.open "select max(id) from cars", dbConnection

message = message & " RecordID: " & rsid(0)

D
ducmis author 3/11/2005

it works thanks./

D
ducmis author 3/11/2005

USE @@IDENTITY ...
set rsid = Server.CreateObject("ADODB.Recordset")

rsid.open "select @@IDENTITY from cars", dbConnection

message = message & " RecordID: " & rsid(0)