System.InvalidOperationException:ExecuteReader需要一个开放且可用的连接。连接的当前状态是连接。 [英] System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is connecting.

查看:83
本文介绍了System.InvalidOperationException:ExecuteReader需要一个开放且可用的连接。连接的当前状态是连接。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这意味着什么?

具体是什么"连接的当前状态是连接的"意思?我知道连接是否已关闭 - 这很明显。但是"正在连接"?我认为这意味着连接已连接但尚未完全连接
。但是我希望超时(因为连接永远不会完成),而不是这个错误。

Specifically what does "The connection's current state is connecting" mean? I understand if the connection is closed - that's pretty obvious. But "Connecting"? I would think this means the connection is connecting but has not connected fully yet. But then I would expect a timeout (because connection never completed), not this error.

谢谢

Thank you

JP

推荐答案

这可能会提供答案:  https://stackoverflow.com/questions/9705637/ executereader-requires-an-open-and-available-connection-the-connections-curren

基本上,如果你经常尝试重用连接,保持连接或者将它作为一个静态对象,你可能会与.Net的连接池机制作斗争。

Essentially, if you are constantly trying to reuse a connection, keeping it open or holding it as a static object you may be fighting against .Net's connection pooling mechanism.

应根据需要打开,使用,关闭和处置连接。

Connections should be opened, used, closed and disposed as needed.

如果这不能为您的错误提供任何线索,那么你可以发布产生错误的示例代码吗?

If this doesn't provide any clue to your error, then could you post example code that produces the error?


这篇关于System.InvalidOperationException:ExecuteReader需要一个开放且可用的连接。连接的当前状态是连接。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆