locked
HELP! With ASP and SQL - "Incorrect syntax " error when trying to write to DB? RRS feed

  • Question

  • User-138270719 posted

    Please look at my code and tell me why I am getting a incorrect syntax error when trying to write to a database with a table named sponsors? It seems like every line I get this error on.

     

     

    <!--#include file="../includes/database/dbconnect.asp"--> ' This file includes the DataConn variable to connect to the database. 

    <%
    dim contact, company, email, intPhone, intCell, address, city, cstate, intZip, package, payment, SQL_Insert
    contact=Request.Form("contact")
    company=Request.Form("company")
    email=Request.Form("email")
    intPhone=Request.Form("phone")
    intCell=Request.Form("cell")
    address=Request.Form("address")
    city=Request.Form("city")
    cstate=Request.Form("cstate")
    zip=Request.Form("zip")
    package=Request.Form("package")
    payment=Request.Form("payment")
    intPhone = Replace(intPhone, "-", "")
    intPhone = Replace(intPhone, "(", "")
    intPhone = Replace(intPhone, ")", "")
    intCell = Replace(intCell, "-", "")
    intCell = Replace(intCell, "(", "")
    intCell = Replace(intCell, ")", "")
    intZip = Replace(intZip, "-", "")
    intZip = Replace(intZip, "(", "")
    intZip = Replace(intZip, ")", "")

    SQL_Insert = "" & _
      " INSERT INTO sponsors " & _
      " (contact,company,phone,cell,address,city,cstate,zip,package,payment) " & _
      "  VALUES " & _
      " ('" & contact & "','" & company & "','" & intPhone & "','" & intCell & "','" & _
      " '" & address & "','" & city & "','" & cstate & "','" & intZip & "','" & _
      " '" & package & "','" & payment & "')"

    DataConn.execute(SQL_Insert)

     

     

    By the way, the table is setup for all variables as strings except for intCell, intPhone and intZip 

    Thank you!

     

    shawn.bordeaux@justrightautosales.com

    Wednesday, October 22, 2008 1:32 PM

Answers

  • User-990694832 posted

    Looks like there is an extra ' on the end and begining of the string.

    Could be a memory leak.

    Use a system.text.string builder to build the string.

     

     

    Hope this helps

    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 22, 2008 2:25 PM

All replies

  • User-990694832 posted

    Looks like there is an extra ' on the end and begining of the string.

    Could be a memory leak.

    Use a system.text.string builder to build the string.

     

     

    Hope this helps

    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 22, 2008 2:25 PM
  • User-138270719 posted

    Good eyes! That did it!

    Wednesday, October 22, 2008 2:26 PM