你连接使用后是否将连接都Close了?
解决方案 »
- 网站紊乱
- 技术分为什么不能当可用分?那要技术分有什么用啊?
- 如何绑定TreeView,使数据是动态显示(数据库的内容)的?
- 问一个关于asp.net treeview 的问题
- c# asp.net 2.0 怎样内嵌qq在线客服
- [五一也着急]用javascript无刷新读取后台数据到TextBox上 + SqlCommandBuilder 批量更新
- .NET发布网站后拷贝到其他机器是否能用?
- 有没有介绍水晶报表的好书
- asp.net调用服务端的WORD
- 大家一起进来研究研究。。。。
- 请讨论一下有关客户端用javascript验证和利用Validator控件验证的差异?
- xml验证问题,一有答案,马上结贴送分
例:SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Integrated Security=SSPI;Initial Catalog=northwind;Max Pool Size=500";
我的一个程序使用了大量如下的数据库访问方式,出现的现象是每运行一定时间(一两天)便会出现只能显示程序的第一个页面(用户登录页面),当输入用户名和口令并点击进入后,就会报错,而且只有重起服务器才能解决。不知道是否是这些代码的问题? //首先,在数据访问组件类(.cs文件)中有以下函数
public SqlDataReader GetProductCategories()
{ SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("ProductCategoryList", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure; // Execute the command
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Return the datareader result
return result;
} //在界面类上有一dataList,界面类调用以上函数的代码如下:
IBuySpy.ProductsDB products = new IBuySpy.ProductsDB();
MyList.DataSource = products.GetProductCategories();
MyList.DataBind();
必须加上myConnection.Close或myConnection.Dispose!