Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    0x80040E14 Syntax error in INSERT INTO statement.

    Hi.

    error:

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    /bookstore/addtobasket.asp, line 11


    Code:

    <%
    dim book_id
    Request.QueryString("book_id")

    dim conn
    set conn=server.CreateObject("ADODB.connection")
    conn.Open "dsn=bookstore"

    conn.Execute "insert into basket (book_id, visitor_id) select " & book_id & ", " &_
    Session("visitor_id")

    conn.Close
    set conn=nothing

    Response.Redirect "showbasket.asp"
    %>


    Thx.

  • #2
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Here's my take:

    I could be wrong but....
    Code:
    dim book_id
    Request.QueryString("book_id")
    I think what you meant to do was assign the result of the queryString to book_id like so:
    Code:
    dim book_id
    book_id=Request.QueryString("book_id")
    Could be wrong? U tell me? Was that the problem?
    Coz if you have assigned a value to the book_id where I see u attempting to insert into your table... you might have been trying to enter blank data into a "zero-length not allowed" field

    Secondly... this what you have for tha insert line:
    Code:
    conn.Execute "insert into basket (book_id, visitor_id) select " & book_id & ", " &_
    Session("visitor_id")

    I'm not sure wot that code is supposed to do, but if its a simple insert it should read (if that book_id and visitor_id are text fields):
    Code:
    conn.Execute "insert into basket (book_id, visitor_id) values "('"  & book_id & "','" & Session("visitor_id") & "')"

    But if they were numeric fields.... lose the single quotes:
    Code:
    conn.Execute "insert into basket (book_id, visitor_id) values "("  & book_id & "," & Session("visitor_id") & ")"
    Last edited by jaywhy13; 02-06-2005 at 04:41 AM. Reason: correction and update to code
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #3
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    Thx for the unswer but it wasn't the problem,

    I solved my problem by adding [ ], [ ] to my code,

    conn.Execute = "INSERT INTO basket ([book_id], [visitor_id]) select " & book_id & ", " & session("visitor_id")

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    what the?!

    anyone know why that fixed it? i thought that was just to do thinks like have a variable named date without it just running Date()

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yea I was SUPER surprised when I saw his response. As far as I kno. The only times that we are required to use the square brackets are when a reserved keyword was used for a field..... And I don't see either of those keywords here.

    Its interesting. I'll keep my ears open to see if anyone can explain why that worked.... I'm puzzled to my friend!
    Last edited by jaywhy13; 02-07-2005 at 11:45 AM.
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished


  •  

    Posting Permissions

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