网站测试小问题 The connection was not closed ……
网址:
www.szdchj.com
点中文版。多进几次就报错了
相关代码如下:
public DataSet ReDataSet(string sSql)
{
try
{
//if (Sconn.State != ConnectionState.Open)
//{
// Sconn.Open();
//}
if (Sconn.State == ConnectionState.Closed)
{
Sconn.Open();
}
DataSet Ds = new DataSet();
OleDbDataAdapter Da = new OleDbDataAdapter(sSql, Sconn);
Da.Fill(Ds);
return Ds;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
CloseConn();
}
}
说明: 屏蔽的3行是原来的,下面3行是我写上去的,我感觉应该和原来是等同的。请指教,小弟在线等
[解决办法]
连接池关闭可能有问题,LZ自己看看哪里还有链接数据库的地方没有关闭的
[解决办法]
DataAdapter会自动打开连接不需要Sconn.open(); 你再试试
public DataSet ReDataSet(string sSql)
{
try
{
//if (Sconn.State != ConnectionState.Open)
//{
// Sconn.Open();
//}
//if (Sconn.State == ConnectionState.Closed)
//{
//Sconn.Open();
//}
DataSet Ds = new DataSet();
OleDbDataAdapter Da = new OleDbDataAdapter(sSql, Sconn);
Da.Fill(Ds);
return Ds;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
CloseConn();
}
}
[解决办法]
closeConn()也去掉吧
[解决办法]