我的C#代码使用SqlConnection
连接到SQL Azure。有时我会面对以下几点:我如何知道实际的SQL Server客户端连接池利用率?
System.InvalidOperationException
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()
// my code calling SqlConnection.Open()
我想找到为什么我面临这个例外。这个例外可能是因为我已经耗尽了连接池,但我不完全确定,如果我确定我想知道我是如何到达那里的。
我的代码可以获得最大池大小和当前池利用率(已用和未用连接数)吗?
[最大池大小设置和联合会在Windows Azure中的SQL数据库(http://blogs.msdn.com/b/cbiyikoglu/archive/2012/09/07/max-pool- size-setting-and-federations-in-windows-azure-sql-database.aspx) – Habib 2013-05-06 11:07:46
@Habib:那是每个连接,它并没有说我已经有多少个连接。 – sharptooth 2013-05-06 11:10:14