Detailed Question About Retrieving a Field Determined by Identity Option in the Table Design
Posted on 2002-03-21
What I would like:
From a Customer Menu page, a user clicks on a "Place New Order" button and is taken to an Order Form page. There are 3 elements on the Order Form page:
1. A grid (grdProducts), displaying product information such as product name, description, price, etc.
2. A form, consisting of a dropdown box to select the product desired, a textbox to input the quanitity desired, and an "Add Item" button.
3. A grid (grdOrderDetails), displaying order details such as product name, price, quantity, subtotal, etc.
Example of Use:
When a user first enters the Order Form page, the grdOrderDetails is hidden (since there are no order details when he first enters). He makes his selection and clicks the "Add Item" button. He is redirected to the Order Form page, where the grdOrderDetails is now shown, detailing what he just entered. He can choose to add another item.
Relevant Tables in Database:
*Orders <- Table Name
-OrderID <- Primary Key
For the OrderID field in the Orders table, I clicked on "Identity" in the table design window (where the coluumn name, datatype, etc. of the fields are specified). Choosing this option automatically increments the OrderID field in the database every time a new record is added. I need to have this OrderID value before the user adds an item, because the same OrderID is used in the OrderDetails table (There is one order record, but there can be many corresponding order details records.) I'm thinking about doing it this way:
PAGE 1: Customer Menu. User clicks on "Place New Order" button.
PAGE 2: Write CustomerID and OrderDate into Orders table -> OrderID created.
PAGE 3: Retrieve OrderID that was created in PAGE 2 & keep in a session variable.
PAGE 4: Order Form.
PAGE 5: Process Order Form by writing OrderID (in a session variable), ProductName, UnitPrice, and Quantity into OrderDetails table. Redirect to Order Form/PAGE 4.
I have been thinking about this for a long time, and I am really stuck. I was hoping this might be a common operation that many of you have come across. Is there a better way to do this?
This is my first post; I am a complete newbie to Visual InterDev and web development in general, so I sincerely appreciate any help you can give me!