Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A customer is entering the order details.Each time he can enter only one order from the list.He want to place an order for 5 items.order id will be automatically generated.But as long as he places the order the id should be constant
Posted
Comments
amitit1989 7-Nov-11 1:57am    
can you please explain "But as long as he places the order the id should be constant",
Please explain in more detail what do you want?
sirisha89 7-Nov-11 2:18am    
I mean to say for all the 5 items the order id should be same

Your question is not clear. But based on my guess I give you this answer.
Actually you need 3 tables(Just sample & add more fields you want). You should separate the items details. One to many.
TblCustomer
-------------
CustomerID
CustomerName

TblOrderMaster
-------------
OrderID
OrderDate
CustomerID

TblOrderDetails
-------------
OrderID
Items
Qty

So the data will be like this
Customer Details
CustomerID CustomerName
----------------------------------------------------
1          Customer 1
2          Customer 2

Order Master
OrderID  OrderDate    CustomerID
----------------------------------------------------
101      01-Nov-2011  1
102      02-Nov-2011  1
103      03-Nov-2011  1

Order Details
OrderID  Items        Qty
----------------------------------------------------
101      BACON        10
101      PIZZA        5
102      BACON        5
102      PIZZA        15
102      DIET COKE    10
103      PIZZA        5


Here the Order 101 contains 2 items, 102 contains 3 items.

Use this[^] for Identity insert.
 
Share this answer
 
Comments
Dylan Morley 7-Nov-11 3:48am    
Yep, header \ detail is the way to go, my 5
thatraja 7-Nov-11 11:35am    
Thank you
Hello,

As per my understanding of question, You can do one thing :

Whenever customer selects first item, at that time just insert record in DB and keep your ID in Session or somewhere else , and then on every insert fetch it again..

I am not sure if this will help you as question isn't clearly written.
 
Share this answer
 
Comments
sirisha89 7-Nov-11 2:46am    
In which context of the query u did't have the clarity

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900