TableAdapter 仅在高流量期间出现错误

发布于 2024-07-14 17:11:24 字数 649 浏览 6 评论 0原文

我正在开发其他人的项目,该项目大量使用了 tableAdapters。 该网站可以运行,但它会定期在事件日志中添加一个条目:

“ExecuteReader 需要一个开放且 可用连接。 连接的 当前状态正在连接。 ”

该网站不会抛出异常,除非流量很高(每秒 5 个以上请求),否则异常是相同的,指向这行代码:

this.Adapter.Fill(dataTable);

堆栈跟踪:位于 System.Data.SqlClient.SqlConnection.GetOpenConnection(字符串 方法)在 System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(字符串 方法、SqlCommand 命令)

我怎样才能停止这个错误? 谢谢。

结果我只得到了一半的图片,当它抛出错误时,错误是:

“已经有一个打开的 DataReader 与此命令相关联的 必须先关闭。”

I'm working on someone else's project that makes heavy use of tableAdapters. The site works but It regular adds an entry in the Event log :

"ExecuteReader requires an open and
available Connection. The connection's
current state is connecting. "

The site doesn't throw an exception though unless there is high traffic (5+ requests per second) the exception is the same, pointing to this line of code:

this.Adapter.Fill(dataTable);

Stack trace: at
System.Data.SqlClient.SqlConnection.GetOpenConnection(String
method) at
System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String
method, SqlCommand command)

How can i stop this error? Thanks.

Turns out i was only getting half the picture, the error, when it would throw an error is:

"There is already an open DataReader
associated with this Command which
must be closed first."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韵柒 2024-07-21 17:11:24

我想说,您可能将同一个连接用于多种目的,其中一个连接被另一个线程关闭。

我建议添加一些跟踪来弄清楚发生了什么。 很难调试这种错误,这些错误只有在生产中才会出现:(

I would say you're probably using the same connection for multiple purposes and one of them is getting closed by another thread.

I'd recommend to add some tracing to figure out what's going on. It's hard to debug this kind of errors, the ones you only get when in production :(

回忆追雨的时光 2024-07-21 17:11:24

如果您似乎超出了数据库允许的打开连接数。 可以通过指定“最小池大小”和“最大池大小”值在连接字符串中进行设置。 我认为最小池大小的默认值是 0,最大池大小的默认值是 100,但我不确定。

尝试改变它们,看看是否有帮助。

If seems like you have exceeded the allowed number of open connections to your database. This can be set in the connection string by giving values for the Min Pool Size and Max Pool Size values. I think the defaults are 0 for Min Pool Size and 100 for Max Pool Size, but I'm not sure.

Try to change them and see if it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文