Long island web design, hosting company
Home About Us Support Products Services Portfolio Contact Us Home

ASP > How to get identity of a new record

Created On: 11/24/2004 9:59:00 AM

Sometimes you need the learn new record number while your are adding a new record. Following example adds a new records to a table and gets the the autonumber or identity of that records.
<%
 Set Con = CreateObject("ADODB.Connection")
 Con.Open strCon
 Con.execute ("INSERT INTO users (email, pword) VALUES ('"& email &"', '"& pword &"')")
 set rs = Con.execute"SELECT @@IDENTITY from users")
 response.write "Last Record ID is : " & rs(0)
%>