Inserting data to a database

Results 1 to 2 of 2

Thread: Inserting data to a database

  1. #1
    Join Date
    Dec 1969

    Default Inserting data to a database

    i am having trouble inserting data from a form into a database my code is,<BR>&#060;%<BR>dim conn<BR>dim SQLinsert<BR>dim qty<BR>dim sizemenu<BR><BR><BR>qty = Request.querystring("qty")<BR>sizemenu = Request.querystring("sizemenu")<BR><BR>&#039;Creat e an ADO Connection and Recordset<BR>set conn=Server.CreateObject("ADODB.Connection")<BR><B R><BR>&#039;Open the Connection<BR>conn.Open "Data Source=" & Server.Mappath("dsdsports.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"<BR><BR> <BR>&#039;Write the SQL statement<BR>SQLinsert="INSERT INTO cart (Quantity, Size) VALUES(&#039;"&qty&"&#039;,&#039;"&sizemenu&"&#039 ;)"<BR><BR>conn.execute(SQLinsert)<BR>conn.Close<B R>set conn=nothing<BR><BR>response.write "The record has been added."<BR> <BR><BR>%&#062;<BR>I get an error message saying "Syntax error in INSERT INTO statement" and its points to the conn.execute(SQLinsert) line as being the problem. Can anybody help me?<BR>Thanks in advance

  2. #2
    Join Date
    Dec 1969

    Default RE: Inserting data to a database

    Are quantity and size numeric fields by any chance?<BR><BR>If so, lose the &#039; marks around them as they denote text<BR><BR>SQLinsert="INSERT INTO cart (Quantity, Size) VALUES("&qty&","&sizemenu&")"<BR><BR>If that doesn&#039;t fix it , do a response.Write SQLinsert and see what you get on screen. It should then become obvious what is going wrong.

Posting Permissions

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