...

View Full Version : Adding to cart problem (What am I missing)



details
07-19-2002, 05:40 PM
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

:confused:

oracleguy
07-19-2002, 07:34 PM
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?

ecnarongi
07-19-2002, 07:38 PM
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&"')"

oracleguy
07-19-2002, 10:04 PM
Originally posted by ecnarongi


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

Yeah that too :eek: I missed that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum