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?
 
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
 
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
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
 
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
 
pkivolowitzAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.