超时时间已过从池中获取连接之前

问题描述:

我得到这个错误每隔几天。我不会看到错误了几天,然后我会得到20左右全部乱舞,在一分钟左右。

I'm getting this error every few days. I won't see the error for a few days then I'll get a flurry of 20 or so all with in a minute or so.

我已经很透彻的去让我用这个基本的设置为我的数据库访问把我的code。

I've been very thorough going throw my code so that I'm using this basic setup for my DB access.

try
{
  myConnection.Open();
  mySqlDataAdapter.Fill(myDataTable);
  myConnection.Close();
}
Catch (Exception err)
{
  if (myConnection.State != ConnectionState.Closed) myConnection.Close();
  throw err;
}

我的理解,这应该执行我的查询,并立即释放连接返回到池中,但如果出现问题,查询的方式,然后我抓住了excpetion关闭我的连接则抛出错误了,最终被困在应用水平和日志和电子邮件我的错误。

The way I understand it this should execute my queries and immediately release the connection back to the pool but if something goes wrong with the query then I catch the excpetion close my connection then throw the error up, which eventually gets trapped at the application level and logs and emails me the error.

即使使用这个在我的code,我至今仍然在这个问题上运行。我能做些什么来诊断问题的根源在哪里?

Even using this throughout my code I'm still running across the issue. What can I do to diagnose the root cause of the issue?

问题是池连接的数量,你可以在游泳池。

The issue is the number of pooled connections you can have in the pool.

在您的连接字符串,你可以添加 最大池大小= 100 属性增加你的池的大小。然而,它听起来像你同时运行一个显著一些SQL查询,这些都是长期运行的。也许你应该着眼于如何既缩短了查询或通过一个连接运行它们按顺序。

In your connection string, you can add the "Max Pool Size=100" attribute to increase the size of your pool. However it sounds like you are concurrently running a significant number of SQL queries, all of which are long running. Perhaps you should look at ways to either shorten the queries or run them sequentially through a single connection.