Max pool size reached error

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Microsoft SQL Server
Post Reply
pvsk123
Posts: 1
Joined: Sat 28 Mar 2015 09:48

Max pool size reached error

Post by pvsk123 » Sat 28 Mar 2015 09:53

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?

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Max pool size reached error

Post by Pinturiccio » Tue 31 Mar 2015 12:04

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?

Post Reply