Hi...
I am getting an error -
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.
---
Please help in solving this...
Is there a particular way or any statement for such type of errors ??
Loading

Abhishek YadavRank #536 · 4.5K reputationPosted Feb 21, 2015, 10:08 AM EST
Basically this error occurs whenever connection pool limit exceeds.This can be resolved by clearing connection pool.
Use SqlConnection.ClearAllpools(); method in Page_Unload event, this will close all the connections or else close all the connections explicitly.
SqlConnection.ClearAllpools() method empties the connection pools. If you don't want to write this method in Page_Unload event, then create 1 button_Click event as shown below.
private void btnClear_Click(object sender, EventArgs e) { SqlConnection.ClearAllPools(); //myLabel.Text = "Pool has been cleared."; }Riddhi ValechaRank #794 · 2.9K reputationPosted Feb 22, 2015, 12:09 AM EST
All my Database functions are in class file (FunctionClass.cs file).
Can I write this -
SQLConnection con = new SQLConnection();
SQLConnction.ClearPool(con);
con.ConnectionString = ""; //Connection string
con.state = ConnectionState.Open();
------------------------------
Or I need to change ??
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 22, 2015, 5:58 PM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 22, 2015, 6:35 PM EST
Hi,
Please refer below link i tmight help you.
http://forums.asp.net/t/1968696.aspx?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+
https://msdn.microsoft.com/en-us/library/aa175863(SQL.80).aspx