出现如下错误,如何解决

enlyse 2003-07-20 11:23:49
Server Error in '/' Application.
--------------------------------------------------------------------------------

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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: 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.]
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +396
System.Data.SqlClient.SqlConnection.Open() +384
didadicom.Components.ProductsDB.GetProductsByTuijian(String strTuijian, Int32 RowNums) in D:\wwwroot\didadicom\Components\ProductsDB.cs:1106
didadicom.index.BindData() in d:\wwwroot\didadicom\index.aspx.cs:56
didadicom.index.Page_Load(Object sender, EventArgs e) in d:\wwwroot\didadicom\index.aspx.cs:46
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
...全文
75 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
007Delphi 2003-07-20
  • 打赏
  • 举报
回复
权限的问题!
enlyse 2003-07-20
  • 打赏
  • 举报
回复
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

dr可以这样关吧

dataset不用关连接吧
Englishgenius 2003-07-20
  • 打赏
  • 举报
回复
贴出你的代码
dongchuanlu 2003-07-20
  • 打赏
  • 举报
回复
每一次数据库连接都因尽快的关闭。
azev 2003-07-20
  • 打赏
  • 举报
回复
检查数据库连接语句..

一定要确保所有的数据库连接在任何情况下都安全关闭
azev 2003-07-20
  • 打赏
  • 举报
回复
这也不是你的全部源码啊..:)

还有如果在下面这一句出了问题
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
你在哪儿关闭数据库?

象你的问题如果重启后运行还这样
最可能的情况是在哪儿出现了一个循环,在这个循环中不断的打开数据库
enlyse 2003-07-20
  • 打赏
  • 举报
回复

这样有问题吗?

dr=mynews.GetnewsByAllHot(5,12);
dlnews9.DataSource=dr;
dlnews9.DataBind();
dr.Close();

public SqlDataReader GetnewsByAllHot(int intNums,int intIs_Hot)
{

// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("newsByAllHotno", myConnection);

// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;

// Add Parameters to SPROC

myCommand.Parameters.Add( new SqlParameter("@RowNums", SqlDbType.Int));
myCommand.Parameters["@RowNums"].Value = intNums;

myCommand.Parameters.Add( new SqlParameter("@Is_Hot", SqlDbType.Int));
myCommand.Parameters["@Is_Hot"].Value = intIs_Hot;

// Execute the command
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

// Return the datareader result
return result;
}

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧