日期:2014-05-18  浏览次数:20378 次

这是数据库超时的错误吗??为什么??
传到服务器上之后,有的页面回报错,为:
Server Error in '/' Application.
--------------------------------------------

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 
Source Error: 


Line 77:  
Line 78: string sql3 = "select PictureName From productPicture where ProductID=" + dr[0].ToString().Trim();
Line 79: string url = DataAccess.SqlHelper.ExecuteScalar(conn.constr(), CommandType.Text, sql3).ToString();
Line 80: ((ImageButton)e.Item.FindControl("ImageButton1")).ImageUrl = url;
红色的为错误,
但是页面一旦刷新就正常了
为什么??这是哪里的错误!

------解决方案--------------------
应该是
没有及时释放数据库链接。
所以访问几个页面后,就会出现那个错误。

你可以检查下是否每次使用完数据库后及时关闭了链接。
------解决方案--------------------
可能数据库打开的连接没有关闭,然后超时
------解决方案--------------------
帮顶!
------解决方案--------------------
哦顶, 顶 顶~~~

还是把代码贴上来 看看吧。 现在大家只是猜~
------解决方案--------------------
try
{
conn.open();



}
catch
{
 
}
finally
{
conn.close();

}
------解决方案--------------------
把SqlCommand.CommandTimeout 设置大一点 默认是30秒

SqlCommand.CommandTimeout 和 SqlConnection.ConnectionTimeout 是两个概念