Vince from Spain
Posts: 658 From: Madrid Spain Status: offline
|
RE: how can i display the record id... - 3/15/2001 20:29:00
Hi there,here is one technique . . . RS.Open tableName, yourAlreadyOpenConnection, adOpenKeySet, adLockOptimistic, adCmdTable RS.AddNew RS("field1") = value1 RS("field2") = value2 ... RS("fieldN") = valueN RS.Update idOfAddedRecord = RS("nameOfAutonumberField") Here is another. This code is executed AFTER adding your new record.
SQL = "SELECT @@IDENTITY" Set RS = Server.CreateObject("ADODB.RecordSet") RS.Open SQL, Connection, adOpenForwardOnly, adLockReadOnly, adCmdText Set RS = Connection.Execute(SQL) jobID = RS(0).Value RS.Close Set RS = nothing The first technique is very much preferred as the second can be fooled in a multi-user environment. By that I mean that if 2 people are accesing you web-page at exactly the same time, one could end up displaying the others id field.
All the best Vince
------------------ Internet Business Solutions S.L.(Spain)
|