Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding master and details records with single click

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I need to add a new master record (order) then order details for that new order with a single click. What is the best approach to this?

I was going to have a form where you enter details for the master record, then another form to enter the order details, click a single button and it adds the master record first, gets the ID from that entered record and then adds the detail records and use the ID from the master record created.

Any easier or more structured approach?
 
I would have a single form where you enter all the information. On the click of the button, validate all of the inputs. When valid, call a stored procedure that inserts the master order record. Pass back the new id(from an identity column if using sql server).
Then, use that id in a call to a second sp to insert the details.

You basically have the concept already designed from what I can tell in your post.
 
On second thought, I would use one procedure all to do both inserts. In the SP, wrap both INSERT calls inside of a Transaction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top