Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET SQL-Server , +
Does any one know what is going on with this error and how can i solve it ?
 
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. at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open()
 
Thanks in advance
Posted 18-Jul-12 0:00am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes. The timeout expired. The timeout expired 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.
 
What this (plain English) message means is that your code waited for a database connection but the timeout ( which you set ) expired before it could get a connection, probably because the number of connection in the pool ( which you set ) was too low for the number of connections you were attempting, or there was a network time out, i.e. the connection between your IIS and your SQL Server was too slow to serve a connection.
  Permalink  
Comments
rushdi obeidat at 18-Jul-12 5:10am
   
ok .. but the number of maximum connection in the application pool is set to be 5000
Christian Graus at 18-Jul-12 5:34am
   
Then that means that your connection to your SQL Server is too slow and timed out. Like I said. You should consider when you ask a question, explaining why you don't think the problem is what the error says. In this case, it's making a guess, and can be wrong.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Execute this query on SqlServerStudio
 
SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame
 
You will get the idea how many connections are open for your database.
I think you are not properly closing connections. Or may be connection is opened somewhere in loop.
  Permalink  
Comments
rushdi obeidat at 18-Jul-12 6:42am
   
thx a lot i will try it.
pradiprenushe at 18-Jul-12 6:43am
   
welcome.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I got this issue recently as one function is creating DbDataReader and returns to other function for iterating. After closing the dataReader in the consumer function it was not closing the connections. So used the below method to create DbDataReader which force to close the connection when the reader closes.
 
Dim reader As DbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return reader
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

use SqlConnection.ClearAllpools(); method in Page_Unload event this will close all the connections
 
it worked out for me .
 
or otherwise close all connections explicitly
  Permalink  
Comments
Rohit_shrma at 14-Aug-14 9:53am
   
SqlConnection doesnt have method ClearAllpools()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 17 Jan 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100