Hi
I've got the following code but it does not return the value of the scope_identity in the variable llID. How can i get its value in a variable for use in another sql statement.
thanks
ian
I've got the following code but it does not return the value of the scope_identity in the variable llID. How can i get its value in a variable for use in another sql statement.
thanks
ian
Code:
SQLstmt = "IF EXISTS(SELECT uniqueid FROM members WHERE uniqueID = '" & _
request("tempid") & "')"
SQLstmt = SQLstmt & "BEGIN "
SQLstmt = SQLstmt & "SELECT 'This record already exists!' "
SQLstmt = SQLstmt & "END ELSE BEGIN "
SQLstmt = SQLstmt & "SELECT 'Record Added' "
SQLstmt = SQLstmt & "Set Nocount on "
SQLstmt = SQLstmt & "INSERT INTO members (cat, BusinessName,BuildingNo,ContactTitle,ContactFirstName,ContactSurname,
Address1,Address2,Address3,Address4,City,County,Postcode,Telephone,Fax,
Email,[URL unfurl="true"]WWW,BusinessDescription,Password,ContactPosition,PairentCompany,[/URL]
DateEst,HeadOfficeTelephone,Keywords1,Keywords2,Keywords3,ExportArea,
NumberOfEmployees, UserName, Turnover, uniqueid)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & objRS8("myID") & "', "
SQLstmt = SQLstmt & "'" & cleansql(BusinessName) & "',"
SQLstmt = SQLstmt & "'" & cleansql(BusinessNo) & "',"
SQLstmt = SQLstmt & "'" & cleansql(ContactTitle) & "',"
SQLstmt = SQLstmt & "'" & cleansql(ContactFirstName) & "',"
SQLstmt = SQLstmt & "'" & cleansql(ContactSurname) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Address1) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Address2) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Address3) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Address4) & "',"
SQLstmt = SQLstmt & "'" & cleansql(City) & "',"
SQLstmt = SQLstmt & "'" & cleansql(County) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Postcode) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Telephone) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Fax) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Email) & "',"
SQLstmt = SQLstmt & "'" & cleansql(WWW) & "',"
SQLstmt = SQLstmt & "'" & cleansql(BusinessDescription) & "',"
SQLstmt = SQLstmt & "'" & cleansql(str1) & "',"
SQLstmt = SQLstmt & "'" & cleansql(ContactPosition) & "',"
SQLstmt = SQLstmt & "'" & cleansql(PairentCompany) & "',"
SQLstmt = SQLstmt & "'" & DateEst & "',"
SQLstmt = SQLstmt & "'" & cleansql(HeadOfficeTelephone) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Keywords1) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Keywords2) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Keywords3) & "',"
SQLstmt = SQLstmt & "'" & request.form("ExportArea") & "',"
SQLstmt = SQLstmt & "'" & NumberOfEmployees & "',"
SQLstmt = SQLstmt & "'" & cleansql(str) & "',"
SQLstmt = SQLstmt & "'" & cleansql(Turnover) & "',"
SQLstmt = SQLstmt & "'" & objRS10("uniqueid") & "')"
SQLstmt = SQLstmt & " select llID = scope_identity() "
SQLstmt = SQLstmt & " Set Nocount off "
SQLstmt = SQLstmt & "END"
Set loRs = objcon.execute(SQLstmt)
llID = loRs("llID")
SQLstmtTemp = "UPDATE tblID set " & _
"DetailsID = " & llID & " " & _
"WHERE UniqueID = '" & strUnique & "'"
objCon.Execute(SQLstmtTemp)