I'm trying to implement transaction functionality.
Code Snippet:
using (TransactionScope transactionScope =
new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(1)))
{
UpdateStuff1(); // ConnectionString1
throw new Exception();
UpdateStuff2(); // ConnectionString2
}
FROM MSDN:
you should call this method only once to inform that transaction manager that the state across all resources is consistent.
Failing to call this method aborts the transaction.
the problem:
The transaction manager does not rollback the changes saved using UpdateSuff1()
.
And even if I don't throw an exception, the changes are still saved in the two databases without calling the Complete method.
Why is that so behaving?
I use the standard ado .net (SqlConnection, SqlCommand, etc.) in the methods.