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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@@identity within asp page

Status
Not open for further replies.

lorca

Technical User
Dec 20, 2005
64
GB
I'm trying to retrieve the last inserted record's id from my sqlstmt below and embedd it in an email, but no joy - doesn't fail but doesn't return the value llID.
excuse the sql string, but i have to do it that way.

thanks
ian

Code:
SQLstmt = "INSERT INTO tablename (Ename, Eorg, Eaddress1, Eaddress2, Eaddress3, Etown, Ecounty, EPostCode, ETel, EFax,  Eemail, Einfo, Econtact, Eother, source, date_received)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & left(replace(request.form("Name"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("Organisation"), "'", "''"),150) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("Address1"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("Address2"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("Address3"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("Town"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("County"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("PostCode"), "'", "''"),50) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("TelNo"), "'", "''"),30) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("FaxNo"), "'", "''"),50) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("email"), "'", "''"),250) & "',"
SQLstmt = SQLstmt & "'" & InformationSubmit & "',"
SQLstmt = SQLstmt & "'" & left(request.form("contact"),50) & "',"
SQLstmt = SQLstmt & "'" & left(replace(request.form("othercontact"), "'", "''"),100) & "',"
SQLstmt = SQLstmt & "'" & source & "',"
SQLstmt = SQLstmt & "'" & request.form("date_received") & "'"
SQLstmt = SQLstmt & ")"

Set objrs = objCon.execute(SQLstmt)

SQLstmt = "SELECT @@IDENTITY AS NewID"
Set objRS = objCon.Execute(SQLstmt)
llID = objRS.Fields("NewID").value

<!--#include file="SendEmailFunctionCDONTS.asp"-->
SendMail "email address","email address" , "from email address", "Online Enquiry Submission", "New online Enquiry received" & llID & vbCrLf

' Close the connection
objCon.Close()
Set objCon = Nothing

Response.Redirect "home.asp?page=1345"
 
sorted it using ncount on and ncount off !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top