Search code examples
vb.netconnection-poolingsqlconnection

SQL connection vb.net – one sql connection object for the application.?


SQL connection – I planned to create one sql connection object inside my own singleton class (say connectionmanager with Reference counting for ‘SQL connection object’ which is a member of the class) and open/close the connection whenever needed. As I like to give high importance for performance. And my application is a desktop based application accessing a remote database server (SQL server 2008), and will use only one connection string, 50 concurrent desktop users may access db server. Please advice.

As like many articles say if the answer is “Connection pooling is taken care by ado.net” – Does that mean that scope of connection pool is entire life of Application instance? Or is it in the scope of SQLConnection object?


Solution

  • Connection pooling is taken care by ado.net” – Does that mean that scope of connection pool is entire life of Application instance?

    Yes. Read MSDN article - SQL Server Connection Pooling (ADO.NET)

    Connections are pooled per process, per application domain, per connection string and when integrated security is used, per Windows identity. Connection strings must also be an exact match; keywords supplied in a different order for the same connection will be pooled separately.