Solved

SQL Update statement in ASP page

Posted on 2007-11-19
4
1,312 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:grunners80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
ID: 20314429

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

Open in new window

0
 

Author Comment

by:grunners80
ID: 20314669
Thanks, i'll give that a go.  Can I request a cookie value for the WHERE clause?
0
 
LVL 16

Accepted Solution

by:
SQL_SERVER_DBA earned 125 total points
ID: 20314743
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
 

Author Closing Comment

by:grunners80
ID: 31409993
That worked a treat! Many thanks!
0

Featured Post

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question