Configuring Connection Pooling in SQL Server Data Provider

by top54u.com 24 Apr, 2008

You can configure the settings of connection pooling for SQL Server .Net Data Provider by using named values for parameters in SQL Server 2005 database connection string. You can enable or disable the connection pooling; by default connection pooling is enabled.

 

Example:
"Server=(local); Integrated Security=SSPI; Database=Northwind; pooling=false"

 

Above connection string has a parameter value false for pooling that disabled the connection pooling. Pooling = true enables the connection pooling which is a default value for connection string.

 

You can also define the maximum and minimum pool size for connection pooling. Following connection string shows the settings to define the minimum and maximum pool size for the application:

 

Example:
"Server=(local); Integrated Security=SSPI; Database=Northwind;
Max Pool Size=100; Min Pool Size=5"

 

Mechanism of Connection Pooling

When an instance of SQL connection is created by passing the SQL connection string to connect the ASP.Net web application with SQL Database, it creates a connection pool and starts adding the connections upto the maximum count of pool configured. When it reaches the maximum value then the request for new connection gets queued for the configured duration.

 

When you are using SQL Server .Net Data Provider then you should take care of connection strings passed for the same database connection coz SQL Server Data Provider is sensitive to spaces between the named value pairs. For example following two connection strings for a similar data source creates two different pools:

SqlConnection conn = new SqlConnection( "Integrated Security=SSPI;Database=Northwind" );
conn.Open();

SqlConmection conn = new SqlConnection( "Integrated Security=SSPI ; Database=Northwind" );
conn.Open();

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:44:30 AM




related videos.....
recent posts.....
top54u ezines.....