Hi
I have almost completed my E-Commerce website and needed help with one of the final implementations.
I need to have an Order Id\Ref upon checking out and thought the best way to go with this would be to...
1. Create an Order Id table in the database.
2. Create a Web Custom Control on the asp page to display the value.
3. Write the code to wire up the plumbing between UI to the DL.
4. Write a list of Order Ids in the database starting from 1 onwards.
I wondered how the auto incrementing of the Order Id can be done. So say that once Order Id 1 has gone how will the page know to display Order Id 2 automatically ready for the next customer?
Thanks
Steven
Loading
SenthilkumarPosted Apr 2, 2012, 11:29 PM
You no need to do it manually by checking next id or the total number of records in the table.
Sql server provides you to keep the identity column in the table. You can configure the seed and increment value and no need to insert. Because it will take care of the order of numbers.
CREATE TABLE Order
(
iOrderID INT IDENTITY(1,1) PRIMARY KEY
,ProductID INT REFERENCES Product(ProductID)
,Qty INT
,OrderDate DATETIME DEFAULT GETDATE()
)
Here you have set the identity column on the orderID and it will start from the 1 and increment by one. When you truncate the table will reset the identity value in the table and when you delete the records it will continue the identity value from where it ends.
Guest UserPosted Apr 2, 2012, 2:38 PM
I now have a solution for the above post.
I am going with the Identity Increment and Increment Seed for the Order Id column in the Database.
This way once an order has been processed all the through to the checkout stage a redirect will then occur to go to an order confirmation page which then fire the Insert to the Database via the code behind page_load.