Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004

    Question Unanswered: increment data in DB(Access) without autonumber

    I am making a e-commerce website USING ASP & Access, each time the cutomer press the CHECKOUT button, for ordering products, the products adds in the Orders table.This portion is working fine, BUT How I can increment a number in Order table's, orderID(number field), for each order(each order can contain many products.)I DON't want to use autonumber.
    Orders(orderID, orderUserID, orderPID, orderQ,orderEntryDateTime)

    My codes are below
    CONST basketPID = 0
    CONST basketPName = 1
    CONST basketPPrice = 2
    CONST basketPQ = 3

    myBasket = Session( "cart" )
    '************************************************* ********'Create an ADO orderConnection and recordset object
    Set orderCon = Server.CreateObject("ADODB.Connection")
    Set orderRs = Server.CreateObject("ADODB.Recordset")
    'Set an active orderConnection and select fields from the database
    orderCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("DataA.mdb")
    orderRS.ActiveConnection = orderCon
    '************************************************* ********
    SQL= "Select * FROM Orders WHERE 1<>1"

    orderRs.LockType = adLockOptimistic
    'orderRs.CursorType = adOpenDynamic
    orderRs.Open SQL
    <p>Your order have been Succesfully placed</p>
    <%= session("name")%>
    FOR i = 0 TO UBound(myBasket)

    orderRS("orderUserid") = session("id")
    orderRs( "orderPID" ) = ( myBasket( basketPID, i))
    orderRs( "orderQ" ) = myBasket( basketPQ, i)
    orderRs( "OrderEntrydate" ) = Now()
    'orderRs( "time" ) = TIME

    please find for me solution, THANKYOU

  2. #2
    Join Date
    Nov 2003
    Christchurch, New Zealand
    Autonumber is the best way to do this.... but since you don't want to, the next best would be something like...

    Update myTable set myTable.OrderId = (select max(myTable.OrderId)+1 from myTable) etc.....

    It's not multi user friendly though.... and you could end up with orders having the same idea or error messages occassionally if two people tried to order at the same time... but generally it would work.

    Why do you not want to use an autonumber?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts