I am trying to add multiple records at one time to an Access database. The form do an INSERT in 3 fields table: itemsOrdered. All work fine, the only problem is that it do the INSEERT only for the first record. If the user choose more records, the asp page add only one record.
What is wrong? Help! Thanks
<%
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
%>
What is wrong? Help! Thanks
<%
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
%>