Reputation: 31
I am executing a stored procedure, with the result returned from the stored procedure I am doing certain operations. Note: Data have been added in certain tables on execution of the stored procedure.
If some error occurs after the execution of the stored procedure, I would like to revert the changes made through the stored procedure as well, the data altered/added through stored procedure ceased to exist.
The code is something like below.
var result = ExecuteStoredProc("SPToBeExecuted");
var spResult = result[0].Cast<Customer>().ToArray();
//Operations performed using spResult
//error occurs in operation performed using spResult
//commit Transaction
Before committing the transaction, how can I revert back the changes made through the stored procedure?
Upvotes: 0
Views: 88
Reputation: 13773
Before committing the transaction, how can I revert back the changes
If you're already working with a transaction, then you should simply rollback the transaction. That's the purpose of a transaction: you either commit it or roll it back in case you want to revert.
Since you haven't posted the actual transaction code, I can't show you a working example.
Upvotes: 1