Hi,
In my asp page I am inserting a record in to the sql server 2005 db as follows...
OpenDataConnect ion()
oConn.BeginTran s
set cm = CreateObject("A DODB.Command")
set cm.ActiveConnec tion = oConn
cm.CommandText ="INSERT INTO t_test( blah blah")
cm.execute
oConn.commitTra ns
set cm = nothing
i would now like to get the id of the record just inserted. i know about @@identity but records are being inserted into this table from multiple sources so i don't think i can gurantee this will be foolproof i.e. i insert a record, then another record is inserted from elsewhere immedialty after, i then run @@identity and it will give me the latter rather than the former...i think ?
Would greatly appreciate any ideas on how to do this. Thanks
In my asp page I am inserting a record in to the sql server 2005 db as follows...
OpenDataConnect ion()
oConn.BeginTran s
set cm = CreateObject("A DODB.Command")
set cm.ActiveConnec tion = oConn
cm.CommandText ="INSERT INTO t_test( blah blah")
cm.execute
oConn.commitTra ns
set cm = nothing
i would now like to get the id of the record just inserted. i know about @@identity but records are being inserted into this table from multiple sources so i don't think i can gurantee this will be foolproof i.e. i insert a record, then another record is inserted from elsewhere immedialty after, i then run @@identity and it will give me the latter rather than the former...i think ?
Would greatly appreciate any ideas on how to do this. Thanks
Comment