Page 1 of 1

Max pool size reached error

Posted: Sat 28 Mar 2015 09:53
by pvsk123
I have a console application where i want to use threads. In the thread i am opening connection where at some point of time it breaks with the error "The timeout period elapsed prior to obtaining a connection from the pool".

Here is my connection string

connectionString="Data Source=INBLRWIT058068\SQL2008R2;Initial Catalog=OMApp;Integrated Security=SSPI;Pooling=True;Min Pool Size=500;Max Pool Size=2000" providerName="System.Data.SqlClient"

Here is the C# code

static void Main(string[] args)
{
WithThread();
}

private static void WithThread()
{
for (int i = 1; i <= 1500; i++)
{
Thread thread1 = new Thread(new ThreadStart(GetOrders));
thread1.Start();
}
}


public static void GetOrders()
{
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand command = new SqlCommand("dbo.GetOrders", connection))
{
command.CommandTimeout = 2;
command.CommandType = CommandType.StoredProcedure;

connection.Open();

using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}", reader[0], reader[1]));
}
}
}
}
}
Can someone help?

Re: Max pool size reached error

Posted: Tue 31 Mar 2015 12:04
by Pinturiccio
pvsk123 wrote:providerName="System.Data.SqlClient"
Could you please tell us which provider you use? Is it dotConnect for SQL Server or System.Data.SqlClient?