In some reason, my application got timeout expired exception. In my code, I close Sql connection in finally block. So that should not have connection leak. Also, I monitor my application from SQL management studio and the max concurrent connections is 5 and should be less than default Max Pool Size (100).
Since I don't specify value of Max Pool Size and Min Pool Size in connection string, I think they should be 100/0.
I list sample code as following and thanks for any help.
Connection string.
Application Name=AppName;Data Source=ServerName;Initial Catalog=DBName;User ID=xxxx;Password=yyyy;Connection Timeout = 0;
public static void GetData(SqlCommand cmd, String connString, ref DataTable dt)
{
SqlConnection Conn = null;
Conn = new SqlConnection(connString);
if( null != Conn)
{
try
{
cmd.Connection = Conn;
cmd.CommandTimeout = 0;
SqlDataAdapter sad = new SqlDataAdapter(cmd);
Conn.Open();
if( Conn.State == ConnectionState.Open)
{
sda.Fill(dt)
}
sda.Dispose();
}
catch(Exception ex)
{
// log exception
}
finally
{
if(null != Conn)
{
if(Conn.State == ConnectionState.Open)
{
Conn.Close();
}
}
}
}
}
Exceptions:
[ExceptionName: InvalidOperationException]
[Message: 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.]