DataAdapter.Fill在共享类中错误 [英] DataAdapter.Fill in a shared class Error

查看:95
本文介绍了DataAdapter.Fill在共享类中错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在共享类中使用DataAdapter.Fill方法,由于同时存在打开的数据读取器,该类正在生成错误,错误为:

已经有与此命令关联的打开的DataReader,必须先关闭它."

所以我试图在连接字符串中设置Mars = true,但没有用.

有什么建议吗?

谢谢.

Hi all ,

I am using the DataAdapter.Fill method in a shared class which is generating an error due to the presence of opened datareaders at the same time and the error is :

"There is already an open DataReader associated with this Command which must be closed first."

So i tried to set Mars=true in the connections string but did not work.

Any suggestion ?

Thanks.

推荐答案

您无法使用适配器填充数据读取器,因此请使用数据表或数据集
you can not fill the datareader with adapter so please use datatable or dataset


DataReader仅向前,以连接方式访问数据.因此,您需要关闭DataReader才能对同一连接执行任何其他操作.

看看这些:
使用DataReader(ADO.NET)检索数据 [ ^ ]
DataReader类 [
DataReader is forward only, connected way to access data. So, you need to close the DataReader in order to do any other operation with the same connection.

Look at these:
Retrieving Data Using a DataReader (ADO.NET)[^]
DataReader Class[^]


这篇关于DataAdapter.Fill在共享类中错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆