Click here to Skip to main content
14,929,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have one to many relation in parent child table. I want to insert records is both table in single transaction. If because of any reason child table records not get inserted then parent record also need to rollback.

How would we achieve this in business layer using

Thanx & Regards

1 solution

The best way to do this is to create it as a stored procedure, but whether you do that or inline the code what you really need to do is create a Transaction, which you either Commit after both inserts have succeeded, or Rollback if either fails.

Exactly how you do that will depend on in-line or SP, and the language you choose, but for SP see here:[^] and for C# see here:[^]

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