ConnectionLifetime attribute in the SqlConnection connection string is not honored

Created a sample code.

                == It has the ConnectionLifetime attribute in the connection String set to 10 secs.

                == Now in the code, i'm having a loop which will open the connection, executes a statement.

    == Waits for 15 secs and then closes the connection.

                == Then waits for 15 secs and then tries to reopen the connection.


== Ironically speaking, after 10 secs, the Pool Manager should flush the existing connection based on the connection lifetime.

== Then for the second connection request, a new connection has to be opened.

== But in this case i don't see it. When i open a new connection, it still pulls up from the existing pool.

== Here is the CODE,

                SqlConnection sqlConn = new SqlConnection("Data Source=*****;Integrated Security=SSPI;Application Name=XXXX;Connection Lifetime=10");

            SqlCommand comm = new SqlCommand("Use Northwind");


            for (int i = 0; i < 3; i++)



                comm.Connection = sqlConn;








== As per the definition of ConnectionLifetime states that, (

                                When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.

A value of zero (0) causes pooled connections to have the maximum connection timeout.


== But the behavior is not as mentioned.


Microsoft has confirmed the same as a BUG and will be investigating more in to this.

Comments (0)

Skip to main content