简体   繁体   中英

How to Rollback Data in vb.net

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM