| |
|
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.
|
 |

10-24-04, 19:37
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
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
|
|

10-24-04, 20:43
|
|
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....
|
|

10-24-04, 20:45
|
|
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
|
|

10-24-04, 21:09
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
Thanks a lot, you are a STAR!
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
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
|
|
|
|
|