PDA

View Full Version : syntax error update statement


2day2die
08-10-2011, 11:06 PM
hi all this is my first post and im new here.
my question is i get this error;

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

/testmap/xml/paycheck.asp, line 36


-----------------------------------------------------
and here is the code of this error;

<%
var1 = Replace(Request("var1"),"'","`")
var2 = Replace(Request("var2"),"'","`")
var3 = Replace(Request("var3"),"'","`")
var4 = Replace(Request("var4"),"'","`")

connect2="DSN=fee;UID=dogan ;PWD=besiktas"

set rs1=Server.CreateObject("ADODB.Recordset")

Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xurl="http://www.mollie.nl/xml/micropayment/?a=check&servicenumber=" & var1 & "&paycode=" & var2

xml.Open "GET", xurl, False

xml.Send ""

HTTPReturnCode = xml.status

x_Result = xml.ResponseText

stringc1 = InStr(x_Result,"<payed>")
stringc2 = InStr(x_Result,"</payed>")

stringc1 = stringc1 + len("<payed>")

stringc2 = stringc2 - stringc1

payed = Mid(x_Result,stringc1,stringc2)

if payed = "false" then

sql_update1 = " Update UYELER SET BAKIYE ='1', WHERE id = '" & var3 & "';"

rs1.open sql_update1, connect2, 1,3

Response.write "false"

if var4 = "noajax" then

Response.redirect("../plus.asp?aktie=m6")

end if

elseif payed = "true" then

'True doorgeven aan AJAX request

Response.write "true"

if var4 = "noajax" then

Response.redirect("../plus.asp?aktie=m5")

end if
end if

%>


so where is error i cant see pls help

Old Pedant
08-11-2011, 08:49 PM
One problem, two possible problems:


sql_update1 = " Update UYELER SET BAKIYE ='1', WHERE id = '" & var3 & "';"

The guaranteed problem: The comma before WHERE is bogus. You only use a comma between multiple set name=value pairs, never after the last one.

Possible problems:
(1) If your BAKIYE field data type is INT then you should *NOT* put apostrophes around the 1.
(2) If your ID field data type is INT then you should *NOT* put apostrophes around the var3 value.

Actually, you should only use apostrophes around either of those values if the fields in question are some kind of text field: TEXT, VARCHAR, MEMO, etc. If they are any kind of number (INT or LONG or DOUBLE) then kill the apostrophes.

USUALLY, ID fields are numbers. And since you are assigning the value 1 to BAKIYE, I would guess that it *probably* is a number, too. So *probably* you don't need or want any apostrophes in that query.

Finally, you don't have to put a semicolon on the end of the query. You can, but it is 100% optional.

So my *GUESS* is that all you need is this:

sql_update1 = "Update UYELER SET BAKIYE =1 WHERE id = " & var3

But, again, it depends entirely on what the data types are of those fields.