Question

I have a page in which there are 3 sections.In the first section,i have some details to save in the Database.I am saving these details through a StoredProcedure(sql) named Procedure1.The details are stored in a table named Table1.There is a Primary key in the table named "ID".This "ID" is inserted automatically in the table.

In the second and third sections, i have Grids for Data Manipulation.The Details are inserted in tables Table2 and Table3 through StoredProcedures(sql),Procedure2,Procedure3 recpectively.

The "ID" which is generated automatically in Table1 needs to be inserted in Table2 and Table3.How can i do this?

The Details in Table1 should get Rollback when corresponding data is not inserted in Table2 and Table3,ie. these 3 sections are to be inserted simultaneously.

Now I have created a StoredProcedure in which i have combined all the 3 procedures.

Now how can i write code to Rollback the details? Or can anyone suggest another method to solve this?

Was it helpful?

Solution

Just use a transaction, and call Transaction.Rollback() on error. It's the database's job to handle the details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top