Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error using @@Identity with Access

Status
Not open for further replies.

Udaman33

IS-IT--Management
Sep 4, 2003
7
US
I am trying to return the record ID from an access database using the autonumber data field.

Connection string:

Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\Inetpub\ Codes.mdb;Persist Security Info=False;"

After the INSERT INTO statement executes, I have inserted the code:

set rsID = Conn.Execute("SELECT @@IDENTITY")
varRecordID = rsID(0)
rsNewID.Close
Set rsNewID = Nothing

When I rem these lines, it works just fine, but with them enabled I get the error message:

Error Type:
Response object, ASP 0185 (0x8002000E)
A default property was not found for the object.

Everywhere I have read says this should work. Any ideas?
 
Access doesn't know what @@Identity is. SQL Server does though. You either need to use a recordset and do an Add and grab the new ID there or do a SELECT MAX(id) as whatever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top