• Register
0 votes
117 views

Problem :

My Query is giving the strange error as follows
there is already an open datareader associated with this command which must be closed first.
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

This issue can happen if you are executing a Query while iterating over the results from another Query. 

Please note that a cause of this can be lazy loading triggered when iterating over the results of some of the query.

It can be solved easily by allowing MARS in your connection string. Please add MultipleActiveResultSets=true to your provider part of the connection string where you are spacifying the Data Source, Initial Catalog, etc. 

This will surely resolve your issue.

9 7 4
38,600 points

Related questions

0 votes
1 answer 3 views
3 views
Problem: I have below code and I am getting exception: There is already an open DataReader associated with this Connection which must be closed first. I am using Visual Studio 2010/.Net 4.0 and MySQL for this project. Basically I am trying to run another SQL ... ==THIS LINE THROWS "C# mySQL There is already an open DataReader associated with this Connection which must be closed first." } } }
asked Apr 24 anika11 32.2k points
0 votes
1 answer 15 views
15 views
Problem: there is already an open datareader associated with this connection which must be closed first.
asked Feb 23 Muneeb Saadii 130k points
0 votes
2 answers 903 views
903 views
Problem : I want to save on the DB the log of a multi threaded processor but I am facing the following error: new transaction is not allowed because there are other threads running in the session. In each tread I have following function : internal bool WriteMyTrace(IResult ... for each of the threads, but there connection with my DB is always in the same way. Anyone have solution on my problem?
asked Dec 5, 2019 alecxe 7.5k points
0 votes
1 answer 5 views
5 views
Problem: I am receiving There is already an object named AspNetRoles in the database. error while attempting to use update-database command in NuGet console. Error: PM> update-database Applying migration '20190407181929_initial'. Failed executing DbCommand (2ms) [Parameters=[ ... ,Class:16 There is already an object named 'AspNetRoles' in the database. You can ask me for any additional information
asked May 4 anika11 32.2k points
0 votes
1 answer 6 views
6 views
Problem: How to call stored procedure in entity framework database first do you have idea to fix ?
asked May 5 ochena 23.3k points
0 votes
1 answer 11 views
11 views
Problem: I am trying to save Employee details, which has references with City. But every time I try to save my contact, which is validated I get the exception: "ADO.Net Entity Framework An entity object cannot be referenced by multiple instances of IEntityChangeTracker"
asked Apr 25 ummeshani 10.8k points
0 votes
1 answer 1 view
1 view
Problem: I get the error: The underlying provider failed on Open
asked Mar 20 ummesalma 29.2k points
1 vote
1 answer 4 views
4 views
Problem: I am attempting to open an already closed .
asked Apr 25 PkGuy 23.5k points
0 votes
1 answer 11 views
11 views
Problem: I recently upgraded/updated Entity Framework in an old project from version 4 or 5 to version 6. Now I get this exception: An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code. Additional information: ... , deleted all the references to old EF files, and re-installed, but nothing works for me. I keep getting this error.
asked Apr 28 Jack20 5.1k points
1 vote
1 answer 2 views
2 views
Problem: I want to transfer APS classic into PHP but Iam geeting an error saying : Provider cannot be found. it may not be properly installed.
asked May 2 PkGuy 23.5k points