When you add a new record, several factors determine where it will be inserted. If you need to come back to this record later, save a bookmark to the current row. However, when you insert records into a table without an index against Microsoft SQL Server, you will not be able to get back to the newly inserted row after you move the current record pointer unless a Requery is performed.
However, if you are using SQL Server and one column has a IDENTITY value you can execute the below script to get the IDENTITY of the row, if the column is also a primary key then you can use the returned value to access the row again.
'A little code to Give Out the Right Cookie
UserId=Request.Cookies("USER")
' If there isn't a cookie then Get One From the SQL Server
if UserId = "" then
Set connOnline = Server.CreateObject("ADODB.Connection")
connOnline.Open "UserDatabase", "login", "password"
sql="INSERT INTO tblUser DEFAULT VALUES SELECT @@IDENTITY 'UserId'"
Set RS = connOnline.Execute(sql)
NextRS=RS.NextRecordset
UserId=NextRS("UserId")
connOnline.Close
' Set Cookie
Response.Cookies("USER")=UserId
end if
Here is the SQL to create the Table in the UserDatabase
CREATE TABLE tblUser (UserId int IDENTITY NOT NULL PRIMARY KEY)