Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: @@Identity to retrieve the value of the newly inserted record in access


Message #1 by "Tom Parker" <tp482@h...> on Tue, 24 Apr 2001 13:27:24
I am using the @@identity to retrieve the autoid field when I do an insert.



strSQL = "INSERT INTO AutoIncrementTest " & _

             "(Description) VALUES ('AutoIncrement Test')"

    cnDatabase.Execute strSQL, , adCmdText + adExecuteNoRecords

    

    strSQL = "SELECT @@Identity"

    Set rsNewAutoIncrement = New ADODB.Recordset

    rsNewAutoIncrement.Open strSQL, cnDatabase, adOpenForwardOnly, _

                            adLockReadOnly, adCmdText



response.write "autoid = " & rsNewAutoIncrement(0).Value





Two things i am not certain of:



1.What happens if two people insert at the same time, from what I can 

gather the two statments are not connected so its like using the max 

record query.



2.How do you use it with a command (parameter query in access)





Any ideas



Thanks 

Tom






  Return to Index