I have situation in which I need to insert a record to the DB from one form (Form1) and then open another form (Form2) in which I have to add more details to the DB and when return back to Form1. Finally, I have to open another form (Form3) from (From1) in which I have to add other details.
My requirement is if there is any failure in Form2 or Form3 the whole process should be cancelled. So all the insertion to the DB in all the forms should be rolled back. I tried implementing TransactionScope with TransactionScopeOption.Required in each of the forms but this seens to be not working the way I need it. In my case if there is a failure in Form3, the insertion in Form2 does not rollback ( I guess since the scope.Complete() is called on each scope).
Required Scenario:
- Form 1 Opens
- Insert in the DB
- Back to Form 1
- Form 2 Opens
- Insert in the same DB
- Back to Form 1
- Form 3 opens
- Failure occurs on Form 3
- Rollback should be called on the insertions in all forms (Form1,Form2 and Form3)