 | 
September 6th, 2008, 03:55 PM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| | Expected end of statement
Hi,
I'm having a problem with an UPDATE statement. This works fine: - 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: - 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!
| 
September 8th, 2008, 08:59 AM
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 924
| |
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
| 
September 8th, 2008, 12:20 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah Age: 32
Posts: 2,363
| |
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
| 
September 9th, 2008, 08:50 AM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| |
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
| 
September 9th, 2008, 09:13 AM
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 924
| |
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
| 
September 10th, 2008, 08:37 AM
|  | Familiar Sight | | Join Date: Nov 2006
Posts: 227
| | 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 -
SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = '1' "
-
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 -
lng_id=Clng(request("db_ID"))
-
SQL = "UPDATE Tests SET Face='"&Face&"', Hairstyle='"&Hairstyle&"', Beard ='"&Beard&"', Moustache='"&Moustache&"' WHERE ID = "&lng_id
-
hope that would solve the problem
regards,
omer
| 
September 10th, 2008, 02:15 PM
| | Newbie | | Join Date: Sep 2008
Posts: 3
| |
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
| 
September 11th, 2008, 07:51 AM
|  | Familiar Sight | | Join Date: Nov 2006
Posts: 227
| | 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
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | 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.
|