Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2005, 07:40 AM
Registered User
 
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple records in a table

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
%>

Fabrizio





Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting multiple records from the same table jscrogg Beginning VB 6 3 June 12th, 2006 05:30 AM
Displaying multiple records in Table thru Paging? InsouciantCoquette Classic ASP Databases 3 February 9th, 2006 12:14 AM
Insert multiple records in a Inner Join Table rylemer Access 1 August 22nd, 2004 07:44 AM
Insert multiple records in a Inner Join Table rylemer Access VBA 0 July 19th, 2004 03:54 PM
How Can I Delete Multiple Records From a Table? Lucy SQL Server 2000 5 May 12th, 2004 05:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.