Monday, 15 September 2014

.net - Behavior of SqlConnection.ClearPool with transactions -


If I pass arguments as a connection used within a transaction (for example For example, in this snippet

  (var tx = new System.Transactions.TransactionScope ()) {var sqlConn = New system.Data. SQLlient.SqlConnection (...) ; / * Do something with the connection * / System.Data.SqlClient.SqlConnection.ClearPool (sqlConn); tx.Complete ();}   

with ClearPool Calling I clear all connections with the same connection string (regardless of transaction) Am I actually closing the connection I'm passing (because it is "affiliate" with the transaction)?

I searched the Internet but I could not find anything. Transaction from MSDN (and) Without behavior, it is clear; Besides, I understand that if I am in the transaction, the connection pool tries to give me the connections used before in that transaction (which still exists) Code> ClearP The behavior of ool is not called with the connection used in the transaction.

Since I have not received any official documentation about this specific scenario, Is available), which imitates this scenario. Before running this sample it is important to stop MS DTC on the test machine - so that we do not deal with distributed transactions and we do not remember that the new SqlConnection has been created. >

In this way I have found that regardless of any transaction related to the SqlConnection.ClearPool connection, the connection to the connection clears all connections of the connection passed as a string.

No comments:

Post a Comment