tags:

views:

32

answers:

1

I have some piece of code in my Website which adds the details into tables. Now I want that if some error occurs the previously entered data should be removed. How can I implement it with the help of transactions??

A: 

We need more details such as what database you are using and so forth. Basically you do this:

Create a transaction

Do some work in the context of that transaction

Do some more work in the context of that transaction

...

If an exception occurred, rollback the transaction, else commit.

BobbyShaftoe
I am using SQL Server 2005 database. I am writung the code in C#
Roshan
Look at SqlTransaction
Sam Saffron