OracleTransaction.dispose: rollback on dispose?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Generally, I try to use "using" in my c# code whenever possible so that I
make sure all my resources are disposed of properly. I'm in somewhat of a
quandry over the OracleTransaction object. Normally I would do something like
....
bool everytyhingSucceeded = true;
using (OracleTransaction transaction = myConnection.BeginTransaction())
{
try
{
// do several things, wrapped in individual try/catches, throwing
// everythingSucceeded to false on errors, etc.

...
}
catch (Exception exception)
{
// some kind of fancy exception handling here.
...
everythingSucceeded = false;
}

if (everythinkSucceeded)
{
transaction.commit();
{
else
{
transaction.rollback();
}
}

What if something goes awry and niether commit() nor rollback() is called?
Since I've wrapped the creation of transaction in a using clause, I'm sure it
will be disposed. But is the object smart enough to rollback and release all
locks if it's disposed off before commit or rollback are called?

Thanks!

Kevin
 

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

Back
Top