【发布时间】:2017-05-21 20:47:16
【问题描述】:
我的网站经常遇到问题。无论我尝试什么,我都无法摆脱它。
在我的 asp.net 项目中,我使用的是 microfost azure 服务器和数据库。我一次又一次地检查了我所有的查询。之后无论我在哪里打开连接,我都会将其关闭。
此外,在我打开我的 sql 连接之前,我几乎会检查每个函数的连接状态,例如:
if (conn.State != System.Data.ConnectionState.Closed) { conn.Close(); }
如果我多次刷新我的主页,我得到了错误,大多数时候没有任何多次刷新我得到了相同的结果。
**The connection was not closed. The connection's current state is open.**
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The connection was not closed. The connection's current state is open.
谁能帮助我在这种情况下我能做些什么?
【问题讨论】:
-
您还有其他联系吗?您是否在其他任何地方打开连接?
-
您是否尝试过使用 try-catch 和调试来确定引发异常的位置?
-
@pookie 我在每个发送命令之前打开我的 sql 连接并在最后关闭它。
标签: sql asp.net connection