Voglio poter aggiungere più prodotti in fase di ordinazione. Ho un insert che aggiunge i valori in una tabella con tre campi: itemsOrdered.
Non mi da errori però mi salva SOLO un record... e non tutti quelli dell'ordine.
Dove ho sbagliato?
Grazie
<%
Sub CreateNewOrder()
Application.lock
if Application("orderID") = "" then
Application("orderID") = 1
end if
intOrderID = Application("orderID")
Session("orderID") = intOrderID
Conn.Execute("INSERT INTO orders " _
& " (orderID, status) values " _
& " ("&intOrderID&", 'OPEN')")
Application("orderID") = Application("orderID") + 1
Application.Unlock
End Sub
Sub AddToOrder(nOrderID, nidprod, nQuant)
sqlText = "INSERT INTO itemsOrdered " _
& " ([orderID], [idprod], [quantity]) values " _
& " ("&nOrderID&", "&nidprod&", "&nQuant&")"
Conn.Execute(sqlText)
End Sub
intidprod = Request.form("intidprod")
intQuant = Request.form("intQuant")
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 idprod = " & intidprod
set rsOrder = Conn.Execute(sqlText)
if rsOrder.EOF then
txtInfo = "This item has been added to your order."
AddToOrder intOrderID, intidprod, intQuant
else
txtInfo = "This item is already in your cart."
end if
%>
Non mi da errori però mi salva SOLO un record... e non tutti quelli dell'ordine.
Dove ho sbagliato?
Grazie
<%
Sub CreateNewOrder()
Application.lock
if Application("orderID") = "" then
Application("orderID") = 1
end if
intOrderID = Application("orderID")
Session("orderID") = intOrderID
Conn.Execute("INSERT INTO orders " _
& " (orderID, status) values " _
& " ("&intOrderID&", 'OPEN')")
Application("orderID") = Application("orderID") + 1
Application.Unlock
End Sub
Sub AddToOrder(nOrderID, nidprod, nQuant)
sqlText = "INSERT INTO itemsOrdered " _
& " ([orderID], [idprod], [quantity]) values " _
& " ("&nOrderID&", "&nidprod&", "&nQuant&")"
Conn.Execute(sqlText)
End Sub
intidprod = Request.form("intidprod")
intQuant = Request.form("intQuant")
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 idprod = " & intidprod
set rsOrder = Conn.Execute(sqlText)
if rsOrder.EOF then
txtInfo = "This item has been added to your order."
AddToOrder intOrderID, intidprod, intQuant
else
txtInfo = "This item is already in your cart."
end if
%>