我在ASP项目中遇到以下错误:
The connection was not closed. The connection's current state is open
Run Code Online (Sandbox Code Playgroud)
在SqlConnection对象上调用.open()函数时.
我试过这个:
if (Conn.State != ConnectionState.Closed)
{
Log.Message(xxx);
try
{
Conn.Close();
}
catch (Exception ex)
{
Log.Error(xxxx);
}
}
Conn.Open();
Run Code Online (Sandbox Code Playgroud)
但这仍然会引发错误.Conn对象声明为:
private static readonly SqlConnection Conn = new SqlConnection(xxxx);
Run Code Online (Sandbox Code Playgroud)
知道我应该在哪里寻找解决方案