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
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"