Note that there are some explanatory texts on larger screens.

plurals
  1. POADO.NET Connection Pooling and implications for AutoClose = True
    primarykey
    data
    text
    <p>Setup:</p> <p>I'm creating a .NET WinForms application in C# to allow our technical support folks to easily perform common tasks against our product's SQL Server 2005 database. The application is using ADO.NET (<code>SqlConnection</code>) to connect to the database. One concern in developing this application was to minimize the overhead of connecting/re-connecting to the database each time a task (query) is initiated. The primary reason for this overhead, from my understanding, is due to the database having the <a href="http://sqlserverpedia.com/wiki/AutoClose" rel="nofollow noreferrer">AutoClose</a> property set to "True". I'd love to change this but unfortunately it isn't under my control. I am also aware that creating a database connection involves some overhead regardless. I had a working implementation of the application that maintained a single connection (unless it was somehow closed before) through the lifecycle of the application. I then stumbled across an MSDN article on <a href="http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx" rel="nofollow noreferrer">connection pooling in ADO.NET</a>. </p> <p>After reading the article (and other questions/answers <a href="https://stackoverflow.com/questions/8223/connection-pooling-in-netmssql">here</a>, <a href="https://stackoverflow.com/questions/9228/ado-net-connection-pooling-sqlserver">here</a> and <a href="https://stackoverflow.com/questions/1058591/net-sqlconnection-class-connection-pooling-and-reconnection-logic">here</a>) it appears that the ADO.NET connection pool will maintain the connection to the database even if my application has properly disposed of its <code>SqlConnection</code> object. The connection will be retained in the pool and is re-usable until it has been idle for a certain time period or is otherwise broken. Thus my work to maintain a single connection in the application seems unnecessary and certainly more dangerous than simply creating/disposing of a <code>SqlConnection</code> each time it is needed.</p> <p>Questions:</p> <ol> <li><p>What implications are present when using ADO.NET Connection Pooling with an SQL Server database with "AutoClose" set to "true"?</p></li> <li><p>I realize I may be oversimplifying when I describe how I believe Connection Pooling works behind the scenes but that aside, is my understanding accurate? If not, where does it need correction?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload