Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 23, 2012 06:01 AM by gopalanmani
May 23, 2012 05:44 AM|LINK
Hi there,I have a web site which issues errors sometimes,I think it's due to not closing connection.
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
As I close my Con,it works fine.
and I Open my connection as below:
public class BasePage:System.Web.UI.Page
public static Commands db = new Commands();
public static SqlConnection Con;
private string ConString;
ConString = System.Configuration.ConfigurationManager.ConnectionStrings["SPConnection"].ToString();
Con = new SqlConnection(ConString);
May 23, 2012 05:50 AM|LINK
You should use using statement for connection.
using (SqlConnection cn = new SqlConnection(connectionString))
SqlCommand cm = new SqlCommand(commandString, cn)
Check following thread:
C# - closing Sql objects best practice
May 23, 2012 06:01 AM|LINK
The general recommendation is to Open/Execute/Close as soon as possible.
and check this url,
Hope its help you