Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Angry Unanswered: 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

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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....

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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

  4. #4
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Thanks a lot, you are a STAR!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •