If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Incorrect syntax near ','.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-24-04, 19:37
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
Angry Incorrect syntax near ','.

The first line of code is the line where the error occurs, I can't figure out what is wrong, have seen many posts but to no avail.

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ','.
/Accommodation/SavePropertyDetails.asp, line 42



call myCon.Execute("INSERT INTO Trim.dbo.accomProperties (CompanyID, NumberOfApartments, " & _
"DistanceToCBD, DistanceToAirport, DistanceToBeach, StarRating, " & _
"ReceptionHours) VALUES (" & _
Request.QueryString("CPYID").item & ", " & Request.QueryString("NUMBEROFAPARTMENTS").item & ", " & _
szCBD & ", " & szAP & ", " & _
szB & ", " & Request.QueryString("RATING").item & ", " & _
szHours & ")")


If I remove myCon.Execute with Response.Write then it goes through, no errors but it doesn't save anything, if I don't touch the code it gives me this error but I can see what is wrong.

Would somebody have an idea?
Thanks
Reply With Quote
  #2 (permalink)  
Old 10-24-04, 20:43
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
yup.... I can give you an idea...

you need to wrap your values in quotes for anything that is a string... for example....
Code:
call myCon.Execute("INSERT INTO Trim.dbo.accomProperties (CompanyID, NumberOfApartments, " & _
"DistanceToCBD, DistanceToAirport, DistanceToBeach, StarRating, " & _
"ReceptionHours) VALUES (" & _
Request.QueryString("CPYID").item & ", " & Request.QueryString("NUMBEROFAPARTMENTS").item & ", " & _
szCBD & ", " & szAP & ", '" & _
szB & "', '" & Request.QueryString("RATING").item & "', " & _
szHours & ")")
.... if Ratting and szB were string values in your database.

You also need to be careful about what you are doing here... I could probably use this page (as it is) to delete every record in your accomProperties table.... possiblt even drop the database... depending on permissions....
Reply With Quote
  #3 (permalink)  
Old 10-24-04, 20:45
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
a better way of doing this is to build a string and then execute it... similar to this...
Code:
sqlString = "INSERT INTO Trim.dbo.accomProperties (CompanyID, NumberOfApartments, " & _
"DistanceToCBD, DistanceToAirport, DistanceToBeach, StarRating, " & _
"ReceptionHours) VALUES (" & _
Request.QueryString("CPYID").item & ", " & Request.QueryString("NUMBEROFAPARTMENTS").item & ", " & _
szCBD & ", " & szAP & ", " & _
szB & ", " & Request.QueryString("RATING").item & ", " & _
szHours & ")"
call myCon.Execute(sqlString)
but you want to take the requests out and apply them to other variables so you can validate them before inserting them
Reply With Quote
  #4 (permalink)  
Old 10-24-04, 21:09
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
Thanks a lot, you are a STAR!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On