What happens to connection object after transaction.Commit or Rollback

I've got a class called Databaseprovider and there I have a static OracleTransaction property called CurrentTransaction. Here's how I assign value to it:

        OracleConnection connection = ConnectionProvider.CreateConnection(conString);
        connection.Open();
        DatabaseProvider.CurrentTransaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);

I've just noticed that after Commit or Rollback the connection property of my transactions gets set to null. Now I wonder what happens to the OracleConnection object I created before? Does it get Closed and disposed too, or it becomes a free, unreachable object?

Answers


The connection remains open until the code has .Close().

Instead of the above code, write the code with using block.

using (OracleConnection connection = ConnectionProvider.CreateConnection(conString))
{
   ....
}

Initialize the expensive objects when needed, dispose it off after the use.


Need Your Help

Stuck on Simple PHP PDO

php mysql pdo

Ive been toying with this for the last half hour and cannot figure out with the life of me what is wrong.

Exception handling: Contract vs Exceptional approach

exception

I know two approaches to Exception handling, lets have a look at them.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.