当前位置:编程学习 > C#/ASP.NET >>

There is already an open DataReader associated with ..."问题的解决

 我在本地测试好的网站,发布网上去有时候 会报这中错误啊,
但是我在用到datareader 的地方都关闭了,CommandBehavior.CloseConnection
 为什么 还报错呢,    网站上所有的datareader我都 关闭了  --------------------编程问答-------------------- This occurs when you have multiple DataReaders open concurrently on the same connection, if you call SqlCommand.ExecuteReader but don't close the SqlDataReader returned by this method before calling it again (either on the same command or another command on the same connection). --------------------编程问答-------------------- 如果要在打开其他的DataReader,先将打开的DataReadr关闭
重新创建一个SqlConnetion --------------------编程问答-------------------- 都关闭了,可能是在逻辑上出现问题,如:这个还没有来得及关闭,就打开了另外一个。 --------------------编程问答--------------------
引用 2 楼 wuyq11 的回复:
如果要在打开其他的DataReader,先将打开的DataReadr关闭
重新创建一个SqlConnetion

有道理 --------------------编程问答--------------------
引用楼主 wangjian15810751604 的回复:
但是我在用到datareader 的地方都关闭了,CommandBehavior.CloseConnection


这根本不是关闭,只是声明将来要随着datareader的销毁而关闭。

这根本不是什么关闭。死读书时没用的。 --------------------编程问答-------------------- 用的什么数据库?数据库给了访问权限没? --------------------编程问答-------------------- CommandBehavior.CloseConnection
连接伴随调用对象被dispose而跟随关闭.
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,