数据库经常连接失败
private void Open()
{
try
{
if (con.State == ConnectionState.Open)
{
con.Close
}
con.Open();
}
catch (Exception)
{
System.Web.HttpContext.Current.Response.Write("数据库连接失败");
System.Web.HttpContext.Current.Response.End();
}
}
我在访问数据库的时候 经常都会出现数据库失败的错误,数据库链接我就是用的上面的函数,每次运行应该都会先关闭数据库再重新链接,怎么还会出这个错误啊?