If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > increment data in DB(Access) without autonumber

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-04, 17:20
raza1 raza1 is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
Question 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.AddNew
orderRS("orderUserid") = session("id")
orderRs( "orderPID" ) = ( myBasket( basketPID, i))
orderRs( "orderQ" ) = myBasket( basketPQ, i)
orderRs( "OrderEntrydate" ) = Now()
'orderRs( "time" ) = TIME
orderRs.Update
Next
orderRs.close
%>

please find for me solution, THANKYOU
Reply With Quote
  #2 (permalink)  
Old 12-19-04, 20:29
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On