|
 |
asp_web_howto thread: Random Numbers
Message #1 by "Mark Berry" <mbfromit@h...> on Fri, 14 Sep 2001 03:54:43
|
|
I want to create a "OrderID" number. How can
I generate a good incrementing number for each
seperate order entered from my shopping cart?
SessionID is out, because it could be repeated.
Using a Application variable is out because it would
be reset if I restart my webserver.
Access and SQL both have the AutoNumber type,
but I can't use them because they increment
each entry. If the cart has more than one item,
then each item has a different order number. So I
need to attach the orderID number, the same orderID,
to each entry or item in my shopping cart.
Any ideas would be appreciated!
Mark
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 14 Sep 2001 15:53:14 +1000
|
|
Mark,
How are you structuring your DB tables? An "order" is an entity that has
attributes like "customer", "date" etc. Items are another entity that have
attributes like "Name", "Cost" etc.
Usually, one would create 1 table to hold the orders, plus a child table to
hold the items in the order. The two would be linked by a 1:M relationship.
TABLE Orders (or Baskets)
OrderID
CustomerID (Foreign Key)
Date
TABLE OrderItems (or BasketItems)
OrderItemsID
OrderID (FK references Orders.OrderID)
ItemID (FK references Items.ItemID)
Quantity
You can then use autonumber/identity fields for OrderID, OrderItemsID, and
ItemsID
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Mark Berry" <mbfromit@h...>
Subject: [asp_web_howto] Random Numbers
: I want to create a "OrderID" number. How can
: I generate a good incrementing number for each
: seperate order entered from my shopping cart?
:
: SessionID is out, because it could be repeated.
: Using a Application variable is out because it would
: be reset if I restart my webserver.
:
: Access and SQL both have the AutoNumber type,
: but I can't use them because they increment
: each entry. If the cart has more than one item,
: then each item has a different order number. So I
: need to attach the orderID number, the same orderID,
: to each entry or item in my shopping cart.
:
: Any ideas would be appreciated!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by "Mark Berry" <mbfromit@h...> on Fri, 14 Sep 2001 08:52:12 -0700
|
|
Duh! I got so cought up in learning
ASP, I forgot how to create a 1:m.
thanks Ken!
>From: "Ken Schaefer" <ken@a...>
>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
>To: "ASP Web HowTo" <asp_web_howto@p...>
>Subject: [asp_web_howto] Re: Random Numbers
>Date: Fri, 14 Sep 2001 15:53:14 +1000
>
>Mark,
>
>How are you structuring your DB tables? An "order" is an entity that has
>attributes like "customer", "date" etc. Items are another entity that have
>attributes like "Name", "Cost" etc.
>
>Usually, one would create 1 table to hold the orders, plus a child table to
>hold the items in the order. The two would be linked by a 1:M relationship.
>
>TABLE Orders (or Baskets)
>OrderID
>CustomerID (Foreign Key)
>Date
>
>TABLE OrderItems (or BasketItems)
>OrderItemsID
>OrderID (FK references Orders.OrderID)
>ItemID (FK references Items.ItemID)
>Quantity
>
>You can then use autonumber/identity fields for OrderID, OrderItemsID, and
>ItemsID
>
>Cheers
>Ken
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>From: "Mark Berry" <mbfromit@h...>
>Subject: [asp_web_howto] Random Numbers
>
>
>: I want to create a "OrderID" number. How can
>: I generate a good incrementing number for each
>: seperate order entered from my shopping cart?
>:
>: SessionID is out, because it could be repeated.
>: Using a Application variable is out because it would
>: be reset if I restart my webserver.
>:
>: Access and SQL both have the AutoNumber type,
>: but I can't use them because they increment
>: each entry. If the cart has more than one item,
>: then each item has a different order number. So I
>: need to attach the orderID number, the same orderID,
>: to each entry or item in my shopping cart.
>:
>: Any ideas would be appreciated!
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
|
|
 |