Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

you can not fill the datareader with adapter so please use datatable or dataset
 
Share this answer
 
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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900