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
C#
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?

Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 28, 2015, 3:30 AM EDT
connectionString="Data Source=INBLRWIT058068\SQL2008R2;Initial Catalog=OMApp;Integrated Security=SSPI;Pooling=True;Min Pool Size=500;Max Pool Size=6000" providerName="System.Data.SqlClient"
Riddhi ValechaRank #794 · 2.9K reputationPosted Mar 28, 2015, 4:25 AM EDT
One Solution is -
SQLConnection.ClearAllPools();
--
Use this static method...
sunil kumar6 reputationPosted Mar 29, 2015, 8:30 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 30, 2015, 1:21 AM EDT
sunil kumar6 reputationPosted Mar 30, 2015, 2:21 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 30, 2015, 2:27 AM EDT
Try this..
1) http://stackoverflow.com/questions/23731876/timeout-expired-the-timeout-period-elapsed-prior-to-obtaining-a-connection-from
2) http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/13/connection-pool-limit-exceeds-error/