Syntax error un update

I have the code below which should update a table, but it has a syntax error I can't find, any help is appreciated.


MM_saveCmd.CommandText ="UPDATE FormsBlb SET Firmid =" & Session("FirmId") & ", Caseid =" & Session("QFcaseid") & ", Userid =" & Session("QFUserId") & ", Activityid =" & Session("QFActivityid") & ", Blobdata = '" & strXML & "') WHERE Blobid = '" & Session("QFBlobid") & "'"
LVL 1
AleksAsked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
my guess is one of the session variables isn't populating. if you do a response.write out to the screen, can you post that?

response.write "UPDATE FormsBlb SET Firmid =" & Session("FirmId") & ", Caseid =" & Session("QFcaseid") & ", Userid =" & Session("QFUserId") & ", Activityid =" & Session("QFActivityid") & ", Blobdata = '" & strXML & "') WHERE Blobid = '" & Session("QFBlobid") & "'"

also, you're opening yourself up to sql injection using this method, you may want to look into parameterized queries
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Looks like you have an extra closing paren

Blobdata = '" & strXML & "')

should be

Blobdata = '" & strXML & "'

BM is correct about using parameterized queries.  At the very least I would do something like below. I only did t his for one field but you can get the idea.  Session variables can get lost easily so it is a good idea to always test that they are available.  Then finally test that it is a number.

 
intFirmID = 0 ' set to default
if  Session("FirmId") <> "" then ' make sure session is set
     if isnumeric(Session("FirmId")) then ' make sure session is a number
         intFirmID = Session("FirmId") ' re set intFirmID
   end if
end if


MM_saveCmd.CommandText ="UPDATE FormsBlb SET Firmid =" & intFirmID & ", Caseid =" & Session("QFcaseid") & ", Userid =" & Session("QFUserId") & ", Activityid =" & Session("QFActivityid") & ", Blobdata = '" & strXML & "') WHERE Blobid = '" & Session("QFBlobid") & "'"

Open in new window

0
 
AleksAuthor Commented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.