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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding to cart problem (What am I missing)

    What am missing in the Sub AddToOrder? When I pass a text value to productCode, it breaks the code. I have the Access DB set for text input? Any suggestions?


    Sub AddToOrder(nOrderID, nProductID, nQuant, nInstall, nProductCode)
    sqlText = "INSERT INTO itemsOrdered " _
    & " (orderID, productID, quantity, installationtype, productCode) values " _
    & " ("&nOrderID&", "&nProductID&", "&nQuant&", "&nInstall&", "&nProductCode&")"
    Conn.Execute(sqlText)

    End Sub


    'Main program
    intProdID = Request.form("intProdID")
    intQuant = Request.form("intQuant")
    strInstall = Request.form("strInstall")
    strProductCode = Request.form("strProductCode")



    set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString

    intOrderID = cstr(Session("orderID"))
    if intOrderID = "" then
    CreateNewOrder
    end if

    sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID
    set rsOrder = Conn.Execute(sqlText)

    if rsOrder.EOF then
    txtInfo = "This item has been added to your order."
    AddToOrder intOrderID, intProdID, intQuant, strInstall, strProductCode
    response.redirect "reviewOrder.asp"
    else
    txtInfo = "This item is already in your cart. "

    end if


  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts

    Re: Adding to cart problem (What am I missing)

    Originally posted by details

    Sub AddToOrder(nOrderID, nProductID, nQuant, nInstall, nProductCode)
    sqlText = "INSERT INTO itemsOrdered " _
    & " (orderID, productID, quantity, installationtype, productCode) values " _
    & " (" & nOrderID & ", " & nProductID & ", " & nQuant & ", "& nInstall & ", " & nProductCode & ")"
    Conn.Execute(sqlText)

    End Sub

    You need to have spaces in there. Did that fix it?
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding to cart problem (What am I missing)

    Originally posted by details
    Sub AddToOrder(nOrderID, nProductID, nQuant, nInstall, nProductCode)
    sqlText = "INSERT INTO itemsOrdered " _
    & " (orderID, productID, quantity, installationtype, productCode) values " _
    & " ("&nOrderID&", "&nProductID&", "&nQuant&", "&nInstall&", "&nProductCode&")"
    Conn.Execute(sqlText)

    End Sub
    I believe he needs single quotes like so: ('"&nOrderID&"', '"&nProductID&"', '"&nQuant&"', '"&nInstall&"', '"&nProductCode&"')"
    I would rather be a lion for a day than a lamb that lives forever.

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts

    Re: Re: Adding to cart problem (What am I missing)

    Originally posted by ecnarongi


    I believe he needs single quotes like so: ('"&nOrderID&"', '"&nProductID&"', '"&nQuant&"', '"&nInstall&"', '"&nProductCode&"')"
    Yeah that too I missed that.


  •  

    Posting Permissions

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