Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add multiple records at one time: INSERT error, it save only one recor

Status
Not open for further replies.

fadege

Programmer
Oct 13, 2005
1
IT
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
%>
 
i dont see a loop or something like that for executing your insert query for all the orders...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top