homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Help! Syntax Error in UPDATE Statement! ASP
sonysg

5+ Year Member



 
Msg#: 3450457 posted 8:27 am on Sep 14, 2007 (gmt 0)

Help me someone please.
i'am developing user login form ,Adding, Viewing the data is fine, but when I try to do the final phase of updating the database (editing a user), i get the following message:

----------------------------------------------------------------------
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in UPDATE statement.
/purchase/UpdateUserRec.asp, line 21

i use the following code to do the update.,plsease note that "rec" is the variable that i pass thru from view form.
---------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#Include file="connection.asp"-->
<%
'DecLare the variables
Dim SQLUpdateEdit

strUser = Request.Form("txtUser")
strPassword = Request.Form("txtPassword")
strARight = Request.Form("txtAccessRight")
strDeptCode = Request.Form("txtDeptCode")
strEmail = Request.Form("txtEmail")

SQLUpdateEdit = "UPDATE usertbl SET"
SQLUpdateEdit = SQLUpdateEdit & " user='" & strUser & "', "
SQLUpdateEdit = SQLUpdateEdit & " Passwd='" & strPassword & "', "
SQLUpdateEdit = SQLUpdateEdit & " ARight='" & strAright & "', "
SQLUpdateEdit = SQLUpdateEdit & " DeptCode='" & strDeptCode & "', "
SQLUpdateEdit = SQLUpdateEdit & " Email='" & strEmail & "'"
SQLUpdateEdit = SQLUpdateEdit & " WHERE user = '"& Request("rec") & ";"

conn.execute SQLUpdateEdit

conn.close
SET conn = Nothing
response.Redirect("EditSuccess.asp")
%>

----------------------------------------------------------------
thanks in advance!

 

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 8:36 am on Sep 14, 2007 (gmt 0)

It's probably this line causing you the problem:

SQLUpdateEdit = SQLUpdateEdit & " WHERE user = "&"'"& Request("rec") & ";"

Try changing it to this:

SQLUpdateEdit = SQLUpdateEdit & " WHERE user = "& Request("rec") & ";"

sonysg

5+ Year Member



 
Msg#: 3450457 posted 8:45 am on Sep 14, 2007 (gmt 0)

hi JuDDer ,tried and paste the above command,
the same error msg still appears.

[edited by: sonysg at 8:46 am (utc) on Sep. 14, 2007]

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 8:45 am on Sep 14, 2007 (gmt 0)

Your code sample appears to have changed since I replied, but you're missing an apostrophe now.

Try changing this line:

SQLUpdateEdit = SQLUpdateEdit & " WHERE user = '"& Request("rec") & ";"

To this:

SQLUpdateEdit = SQLUpdateEdit & " WHERE user = '"& Request("rec") & "' ;"

sonysg

5+ Year Member



 
Msg#: 3450457 posted 8:48 am on Sep 14, 2007 (gmt 0)

STILL the same error msg appear .no idea.

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 8:51 am on Sep 14, 2007 (gmt 0)

Try printing the command to the screen by adding response.write SQLUpdateEdit and then commenting out the execute and redirect code:

response.write SQLUpdateEdit
'conn.execute SQLUpdateEdit

conn.close
SET conn = Nothing
'response.Redirect("EditSuccess.asp")

that will print the command string to your screen so you can look to see what values are being used for your variables

sonysg

5+ Year Member



 
Msg#: 3450457 posted 9:05 am on Sep 14, 2007 (gmt 0)

the query is something like this
think the statement is ok, but got no idea why cannot save .

UPDATE usertbl SET user='KAWARA', Passwd='kawau', ARight='USER', DeptCode='ACCTS', Email='kawara@yahoo.com' WHERE user = 'KAWARA' ;

thanks

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 9:10 am on Sep 14, 2007 (gmt 0)


I can't see anything there that's causing you the error. Have you tried removing the ; from the end of the statement just in case thats something to do with it?

Everything else looks fine to me so I'm at a loss as well

sonysg

5+ Year Member



 
Msg#: 3450457 posted 9:14 am on Sep 14, 2007 (gmt 0)

after remove ';'.IT WORKS and rock!
ok already!JuDDer!
big thanks

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 9:19 am on Sep 14, 2007 (gmt 0)

We try and help through the forums where possible so if somebody else has the same problem they can read the whole thread to see what was tried and worked/didn't work.

Do all of the column names in your update statement exactly match the column names in your database?

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 9:19 am on Sep 14, 2007 (gmt 0)


Oh it works :)
Great job!

sonysg

5+ Year Member



 
Msg#: 3450457 posted 9:28 am on Sep 14, 2007 (gmt 0)

after remove ';'.IT WORKS
but i make a mistake then i realise it actually didn't work out!

SQLUpdateEdit = SQLUpdateEdit & " WHERE user = '"& Request.querystring("rec") & "'"

response.write SQLUpdateEdit
'conn.execute SQLUpdateEdit

conn.close
SET conn = Nothing
response.Redirect("EditSuccess.asp")

%>

it direct to EditSuccess.asp but the table is not updated
after i remove ' for conn.execute SQLUpdateEdit
the same error message appear again.WEIRD~~

Help needed again.

JuDDer

10+ Year Member



 
Msg#: 3450457 posted 10:08 am on Sep 14, 2007 (gmt 0)


Is the "rec" querystring definitely being sent to this page?

sonysg

5+ Year Member



 
Msg#: 3450457 posted 12:28 pm on Sep 14, 2007 (gmt 0)

Judder i do PM your my attachment,hope you can resolve the problem for me.
Thanks

eugene

sonysg

5+ Year Member



 
Msg#: 3450457 posted 1:13 am on Sep 22, 2007 (gmt 0)

hi all,
not sure whether can help me to check the code
i have uploaded to webspace for those experts to tried it out ...
[ymca.sg...]

If happen that anyone can resolve the error ,post the comment over here.

THank in advance

sonysg

5+ Year Member



 
Msg#: 3450457 posted 12:13 pm on Sep 27, 2007 (gmt 0)

anyone can help?
still stuck on it.

thanks

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved