• Register
0 votes
36 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.
by (6.9k points)  

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.

by (36.1k points)  
...