Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 6th, 2008, 03:55 PM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default Expected end of statement

Hi,

I'm having a problem with an UPDATE statement. This works fine:

Expand|Select|Wrap|Line Numbers
  1. SQL = "UPDATE Tests SET Face='"&Face&"', Eyes='"&Eyes&"', Glasses ='"&Glasses&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = 1"
but if I add Hairstyle, Haircol, HairXcoord or HairYcoord, I get an error, e.g. this doesn't work:

Expand|Select|Wrap|Line Numbers
  1. SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = 1"
The error points to Hairstyle (or Haircol, or whichever one I put in), but I have checked that the field names are correct and that they have values in the Flash file I call the ASP from, so I have no idea what is going wrong. Any suggestions?

Thanks!
Reply
  #2  
Old September 8th, 2008, 08:59 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hi JenMac,

You are certain that there are values being passed into the SQL string? Also, do any of the values you are passing in contain single quotes which, as SQL String delimiters, could cause an error?

Dr B
Reply
  #3  
Old September 8th, 2008, 12:20 PM
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Age: 32
Posts: 2,363
Default

Usually "Expected End of Statement" means you are missing or have an extra quote mark or you have some other really stupid syntax error. Don't feel ashamed, we've all done this and then felt stupid when we found it.

Jared
Reply
  #4  
Old September 9th, 2008, 08:50 AM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default

Thanks for your replies.

I decided to change the names I gave the variables in the ASP file - I changed 'Haircol' to 'Col', 'Hairstyle' to 'Style', etc, and it works fine now. I had checked and re-checked the syntax - there were definitely no extra or missing ' and the the values are all numberical, so no ' in them either.

I really don't understand why ASP would have a problem with my variable names, it's not like 'Haircol' is a protected word! If anyone ever comes up with an idea about why it caused a problem, please let me know!

Thanks again for your help.

Jen
Reply
  #5  
Old September 9th, 2008, 09:13 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hi Jen,

That is very strange! I would probably still guess that you had some bug in there somewhere because I can't think of any reason why your original variable names wouldn't have worked.

At least it's working now!

Dr B
Reply
  #6  
Old September 10th, 2008, 08:37 AM
omerbutt's Avatar
Familiar Sight
 
Join Date: Nov 2006
Posts: 227
Default

Quote:
SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = 1"
hi firstly the above sql statement are you ,.......or will you be continiously comparing the ID with 1 if so then do write it between the single quotes for example
Expand|Select|Wrap|Line Numbers
  1. SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = '1' "
  2.  
if not then do try the following ,
if it is not going to be a hard coded string then it would be comming from else somewhere in that case type cast it into Clng() and then compare it for example i will assume that the ID is Comming from a prev page
Expand|Select|Wrap|Line Numbers
  1. lng_id=Clng(request("db_ID"))
  2. SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = "&lng_id
  3.  
hope that would solve the problem
regards,
omer
Reply
  #7  
Old September 10th, 2008, 02:15 PM
Newbie
 
Join Date: Sep 2008
Posts: 3
Default

Hi,

The ID is just a test at the moment, you are right - I will be changing this code once I have the database fully set up. At the moment, there is only one record, which has an ID of 1. Thanks for the help with the code for when I do get round to it, though!

Jen
Reply
  #8  
Old September 11th, 2008, 07:51 AM
omerbutt's Avatar
Familiar Sight
 
Join Date: Nov 2006
Posts: 227
Default

Quote:
Originally Posted by JenMac
Hi,

The ID is just a test at the moment, you are right - I will be changing this code once I have the database fully set up. At the moment, there is only one record, which has an ID of 1. Thanks for the help with the code for when I do get round to it, though!

Jen
yeah sure jen any time
regards,
Omer Aslam
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles