SqlTransaction and Dispose

W

Wells Caughey

I have looked in the documentation and I have looked in Google, but I cannot
seem to find an answer: If a transaction has been opened and the transaction
is disposed before calling Commit or Rollback, am I guarenteed that the
transaction will be rolled back? For example:

try
{
sqlConnection.Open();
using(sqlTransaction = sqlConnection.BeginTransaction())
{
/// do stuff but do not call sqlTransaction.Commit() or
sqlTransaction.Rollback()
/// ...
} /// <- will the transaction be rolled back here?
}
finally
{
sqlConnection.Close();
}

Thanks,
Wells
 
W

Wells Caughey

Thanks for the reply Nicole. Rolling back a transaction on Dispose is what
I expected, but I just needed that verification...

Wells
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top