Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Update statement in ASP page

Posted on 2007-11-19
4
Medium Priority
?
1,314 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 500 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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