How do I get the Unique ID or Auto ID of the record I just entered? I have spent considerable amount of time in various forums and this is one of the most asked questions. The solution is really quite simple.
Nuts Own Code

Asp Directory

Nuts Web Search
Web Directory
Web Search

Nuts ASP Code
Functions
Scripts
Tutorials
Wizards
Fonts
Download Fonts
Download Dll Files
Dll Files
Relaxing Games
Online Games
Take Our Poll
Do you use .Net?
Yes
No
Not Yet
Dot What?
Really, Take It!
Get The Source
About Nuts4Asp
Privacy
Contact Us
Arts
Movies, Television, Music
Business
Jobs, Industries, Investing
Computers
Internet, Software, Hardware
Games
Video Games, RPGs, Gambling
Health
Fitness, Medicine, Alternative
Home
Family, Consumers, Cooking
Kids and Teens
Arts, School Time, Teen Life
News
Media, Newspapers, Weather
Reference
Maps, Education, Libraries
Regional
US, Canada, UK, Europe
Science
Biology, Psychology, Physics
Sports
Baseball, Soccer, Basketball
World
Deutsch, Español, Français, Italiano, Japanese, Nederlands, Polska, Svenska
Help build the largest human-edited directory of the web
Assuming your connection is named Conn, that it is an include file in a directory for connections, here is the solution for getting the ID. (Go get a good understanding of how and why to do this.)

<%Response.Buffer=TRUE%>
<!-- #Include Virtual="conn_strings/myConn.asp" -->

<%
DIM x_1 ,x_2, uniqueID
x_1 = "something"
x_2 = "something else"

SQL="INSERT INTO myTable ('" & x_1 & "','" & x_2 & "')
Conn.Execute(SQL)

Set RS = Conn.Execute( "SELECT @@IDENTITY" ) 
myID = RS("ID")

RS.Close
SET RS = NOTHING

Conn.Close
SET Conn = NOTHING
%>
<HTML>
<HEAD>
<TITLE>
Get the ID of the record entered.</TITLE>
</HEAD>
<BODY>

The ID number id <%=myID%>

</BODY>
</HTML>

Bad or missing query parameters in request.

Copyright © 2001-2008 Nuts4Asp.com
All other names used are property or copyright of their respective owners.