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 SQL statement error

Status
Not open for further replies.

cruford

Programmer
Dec 6, 2002
138
US
Here is the code I'm working on:

Select Case nErr
Case "0"
sSQL = "SET NOCOUNT ON;" &_
"INSERT INTO ztblDiabeticLog (LoggedDate, FirstName, MiddleInitial, LastName, InsVerified, SignedCopy, OnFile, AOBDate, SalesRep, PodNumber, EnteredBy) VALUES ('" & Now() & "', '" & sFN & "', '" & sMI & "','" & sLN & "', " & iIV & ", '" & sSignedOn & "', " & iCopy & ", '" & sAOBDate & "', '" & sRep & "', '" & sPod & "', '" & request.Cookies("UserID") & "');" &_
"SELECT @@IDENTITY AS NewID;"
Response.Write sSQL & "<br>"
Set RS = conn.Execute(sSQL,,1)
NoteID = RS.Fields("NewID")
sSQL = "INSERT INTO ztblDiabeticNotes (DID, Notes, EnteredBy, TimeDate) VALUES (" & NoteID & ", '" & sNotes & "', '" & request.Cookies("UserID") & "', '" & now() & "')"
Response.Write sSQL
Set RS = Conn.Exectue(sSQL,,1)
Response.Redirect("Diabetics_Main.asp")
Case "1"
Response.Write ErrMsg
Response.Write "<li>Please use the BACK button and fill in the missing fields"
End Select

The response.write sSQL is just so I can see the values for testing. My problem is the first SQL statement executes and gives me back @@IDENTITY fine. The second SQL statemtent is throwing up this error:


ADODB.Connection error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/Sales/Diabetics_Submit.asp, line 75


Below is what is being written to the ASP page. I can copy and paste this into SQL's query analyzer and run it and it will insert the row, but it will not do it from the ASP page????

INSERT INTO ztblDiabeticNotes (DID, Notes, EnteredBy, TimeDate) VALUES (65, 'test', 'XXXXXX', '10/6/2004 9:57:49 AM')
 
Nevermind I mispelled "execute" in my statement. Guess spell checking is good practice :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top