我的 C# 代码用于SqlConnection
连接到 SQL Azure。有时我会面临以下情况:
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()
我想找出为什么我面临这个例外。异常可能是因为我已经用尽了连接池,但我不完全确定,如果我确定我想知道我是如何到达那里的。
我的代码是否可以获得最大池大小和当前池利用率(已使用和未使用的连接数)?