views:

28

answers:

1

I have recently started encountering Database connection issues with SQL Server on my development machine.

System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool

How can I monitor the connection pool to figure out what is happening?

Further Info:

I haven't had much luck with this - I'm definitely not leaking connections. Every connection is inside a using statement.

When the problem does occur, I have the Performance Monitor window open and it's not showing anywhere near the limit of the pool (which is 100) - generally around 2 - 5 connections, so I don't think the pool is being exhausted so maybe it's a timeout.

However, I have set the ConnectionTimeout to 0 - which, according to the documentation, means it should wait forever to connect - but I'm not seeing this.

When it does occur, it happens fairly quickly - I'm running under the debugger from VS2010 - starting a new instance of my application - and it might happen within a second or two of starting - in starting up the app there are several queries that happen. The actual SQL Server I'm running against is SQL Express 2008. Maybe I should try running it against SQL Server 2008 and see if I see any different behaviour.

Any other ideas?

+2  A: 

Take a look at the ADO.NET Performance Counters related to pooling.

Your described symptom is often an indication that you are leaking connections. Make sure all connections are disposed when you are finished with them, preferably by wrapping in an using statement.

Mitch Wheat
Agree. Pretty hard to max a pool generally
gbn