Timeout expired.请问这是什么错误,我被困扰了好久了.help me! thank you!
错误信息如下:
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. 每次实例化个实例conn后,我都有去关闭的conn.close(),但打开网页,查看几次后,总会出现以上的毛病,为什么呢?
错误信息如下:
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. 每次实例化个实例conn后,我都有去关闭的conn.close(),但打开网页,查看几次后,总会出现以上的毛病,为什么呢?
public BaseOpDataBase()
{
//
// TODO: 在此处添加构造函数逻辑
//
string constr = System.Configuration.ConfigurationSettings.AppSettings["connstr"];
if (constr == "" || Object.Equals(constr, null)) constr = "Server=" + host + ";UID=" + users + ";PWD=" + password + ";Database=" + database;
connection = new SqlConnection(constr);
try
{
connection.Open();
}
catch (System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
} }我每次要调用的时候,就实例化 BaseOpDataBase bd = new BaseOpDataBase(),数据操作完成后,就bd.close()掉,为何还会出现那样的错误呢?
SqlConnection conn = new SqlConnection("server=localhost;database=master;uid=;pwd=;Connect Timeout=90");SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandTimeout = 80000;
在finally 中去关闭啊
try
{
.....
}
catch()
{
....
}
finally
{
conn.close();
}
{
connection.Open();
}
catch (System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}
finally
{
connection.Close();
}