Does an ODBCTransaction rollback when object goes out of scope with out a commit?

The title contains most of the question (if not all).

Suppose you have an ODBCTransaction and use it in a block of code.

If the ODBCTransaction object goes out of scope without having called the Commit method, does the transaction automatically roll back or must Rollback be explicitly called?

Thanks
pkivolowitzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
What do you mean it goes out of scope? how can it go out of scope before you call either commit or rollback. Could you elaborate on this or a code snippet?
0
pkivolowitzAuthor Commented:
Really, that's unclear?

A transaction is declared within a scope. The transaction is used. An exception happens. The scope is exited without the transaction being committed. The transaction object "goes away" - is it automatically rolled back as part of the object's destruction?

Thanks
0
SriVaddadiCommented:
When an exception occurs, you have to catch the exception and rollback the transaction. You cannot rely on the object's destruction to rollback ur transaction
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

pkivolowitzAuthor Commented:
Can you point me to a bit of documentation which states this?

What you're saying is very likely true as object destruction is "lazy" isn't it?

Thanks
0
SriVaddadiCommented:
Ideally, we are supposed to either commit or rollback the transaction we started before even it goes out of scope regardless of success or error path.

Check out this good article by Juwan Lowy one of my fav authors

http://msdn.microsoft.com/en-us/library/ms973865.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pkivolowitzAuthor Commented:
Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.