Computer Help Forum and Programming Advice :: View topic - sql command help
View previous topic :: View next topic
Author
Message
cpl_hicks Freshman Joined: Feb 01, 2005 Posts: 2
Posted: Wed Feb 02, 2005 12:38 am Post subject: sql command help
im trying to run the following sql command string in a asp webpage, i run the command and i keep recieving erors on the syntax, ive tried looking at it and debuggin it my self, but any more time spent on this and i think i will have to gouge my own eyes out
the code
sqlString = "INSERT INTO title " &_
"( jhm_tit_name, jhm_tit_price, jhm_tit_format, " &_
"jhm_tit_artist, jhm_tit_image, jhm_tit_category, " &_
"jhm_tit_status ) VALUES ( " &_
" '" & productName & ", " &_
" " & productPrice & ", " &_
" '" & productFormat & "', " &_
" '" & productArtist & "', " &_
" '" & productImage & "', " &_
" '" & productCategory & "', " &_
productStatus & " )"
the error shown
Syntax error in string in query expression '', , '', '', '', '', )'.
the sql as shown with reponce.write in webpage
INSERT INTO title ( jhm_tit_name, jhm_tit_price, jhm_tit_format, jhm_tit_artist, jhm_tit_image, jhm_tit_category, jhm_tit_status ) VALUES ( ', , '', '', '', '', )
Back to top
theq Freshman Joined: Jan 18, 2005 Posts: 4
Posted: Thu Feb 03, 2005 5:51 am Post subject:
The syntax error has to do with the fact your missing a '
Try this
sqlString = "INSERT INTO title ( jhm_tit_name, jhm_tit_price, jhm_tit_format, jhm_tit_artist, jhm_tit_image, jhm_tit_category, jhm_tit_status )"
sqlString = sqlString & "VALUES ( '" & productName & "','" & productPrice & "','" & productFormat & "','" & productArtist & "','" & productImage & "','" & productCategory & "','" &_
productStatus & "')"
Back to top
theq Freshman Joined: Jan 18, 2005 Posts: 4
Posted: Thu Feb 03, 2005 5:53 am Post subject:
Remember that SQL Syntax uses '
so when you do " & string & " you need ' on the outside of your "'s
giving you '" & string & "'
Back to top
Jon Web Design Admin Joined: Jul 12, 2004 Posts: 72
Back to top
cpl_hicks Freshman Joined: Feb 01, 2005 Posts: 2
Posted: Thu Feb 03, 2005 8:25 am Post subject:
woot
*starts dancing madly around the room, giveing imaginary high fives*
it works it works it works
sorrry for my madness there, but looking at the same piece of code for several hours a day for the last three days has turned my slightly mad
anyway thanks for the hewlp, i just knew it would be something stupid
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum