SQL Update statement in ASP page

I'm currently trying to update a small database using a sql statement on an asp page.  The line of code reads as follows:

"UPDATE tbl_Personal SET Email="request.form("email")" WHERE Username="request.cookies("MyCookie")("Username")""

This gives the error "expected end of statement".  I'm guessing it's a syntax error as if I replace the line with the following:

"UPDATE tbl_Personal SET Email='a@a.com' WHERE Username='John'"

...it works as expected and updates the record.  I've tried various syntaxes and tried declaring the textbox value and cookie value as variables but I'm still stuck.  Hope someone can help!

Thanks
grunners80Asked:
Who is Participating?
 
SQL_SERVER_DBAConnect With a Mentor Commented:
you can but, the syntax you had the statement in didn't make sense...just remember to put your variables in the correct format...like I did with email and username
0
 
SQL_SERVER_DBACommented:

"UPDATE tbl_Personal SET Email= '" & request.form("email") & "' WHERE Username='" & TXTUsername.TEXT &"')"

Open in new window

0
 
grunners80Author Commented:
Thanks, i'll give that a go.  Can I request a cookie value for the WHERE clause?
0
 
grunners80Author Commented:
That worked a treat! Many thanks!
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.