• Register
0 votes
62 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

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
2 answers 432 views
432 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 68 views
68 views
Problem : I have one entity type called product which is generated by the entity framework. I have tried to write below query public IMyQueryable<Product> GetProducts(int myCategoryID) {     return from prod in db.Products     where prod.CategoryID== myCategoryID     select ... one select new Product { Name = p.Name}; it miraculously works correctly. How can I perform the custom select section?
asked Jan 27 jwilliam 3.9k points
0 votes
1 answer 73 views
73 views
Problem : I am getting bellow error related to datetime the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 251 views
251 views
Problem : When I am attempting to connect to MSSQL database via ASP.NET online, I will often get the below error when two or more people try to connect simultaneously: ExecuteReader requires an open and available Connection. The connection's current state is Connecting. My site works fine on the localhost server. May I know what might have gone wrong with my site and how can I fix the error?
asked Jan 31 jwilliam 3.9k points
0 votes
2 answers 201 views
201 views
Problem : Currently I am migrating from the Identity 1.0.0 to Identity 2.0.1. But the migrations code generated is nothing about the new IdentityUser. And It does not even add the new columns. So I tried to make the new project and also I ... current context At below line IdentityResult result = await UserManager.CreateAsync(user, model.Password); Any clue about the solution on my above problem?
asked Dec 25, 2019 alecxe 7.5k points