Sqlinternalconnectiontds validateconnectionforexecute

Sqlinternalconnectiontds validateconnectionforexecute

By: Levon4eg Date of post: 20.06.2017

This can happen if you execute a query while iterating over the results from another query. It is not clear from your example where this happens because the example is not complete.

c# - There is already an open DataReader associated with this Command which must be closed first - Stack Overflow

One thing that can cause this is lazy loading triggered when iterating over the results of some query. This can be easily solved by allowing MARS in your connection string. In my case, using Include solved this error and depending on the situation can be a lot more efficient then issuing multiple queries when it can all be queried at once with a join.

It appears that you're calling DateLastUpdated from within an active query using the same EF context and DateLastUpdate issues a command to the data store itself. Entity Framework only supports one active command per context at a time. I also noticed you're calling functions like FormattedAccountNumber and FormattedRecordNumber in the queries.

Unless these are stored procs or functions you've imported from your database into the entity data model and mapped correct, these will also throw excepts as EF will not know how to translate those functions in to statements it can send to the data store.

Also note, calling AsEnumerable doesn't force the query to execute.

Until the query execution is deferred until enumerated. You can force enumeration with ToList or ToArray if you so desire. I donot know whether this is duplicate answer or not. If it is I am sorry. I just want to let the needy know how I solved my issue using ToList. ToList to convert object read from db to list to avoid being reread again.

Hope that would work for it. If you are publishing and overriding container on Settings tab, you can set MultipleActiveResultSet to True. You can find this option by clicking Advanced I had the same error, when I tried to update some records within read loop. I am using web service in my tool, where those service fetch the stored procedure. I have fixed by specifying the Synchronized attribute for those function fetches the stored procedure. By posting your answer, you agree to the privacy policy and terms of service.

By subscribing, you agree to the privacy policy and terms of service.

Stack Overflow Legal nurse consultant work from home Developer Jobs Documentation beta Tags Users.

Sign up or log in to customize your list. Tour Start here for a quick overview of usd exchange rate in delhi site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it vincent launay tribuforex takes a minute: There is already an open DataReader associated sqlinternalconnectiontds validateconnectionforexecute this Command which must be closed first Ask Question.

I have this query and I get the error in this function: Accounts from guranteer in account. There forex trading companies in egypt already an open DataReader associated with this Command which must be closed first.

An error occurred while executing the command definition. See the inner exception for details. DateLastUpdated Int64 creditorRegistryId, String accountNo in D: DotnetSparrow 8, 50 Can you give the stack trace? I have added trace in question.

"There is already an open DataReader associated with this Command which must be closed first" explained – Tips and tricks from a Developer Support perspective.

While the answer to this question CAN work - it is NOT the best option to use in almost ALL situations. Instead, the problem is caused by yahoo forex data api COMMON problem with code in the vast majority of cases.

Campbell Sep 26 '13 at Jordan Crittenden 1 5 Ladislav Mrnka k 49 This worked for me. If you want to read more about Enabling Multiple Active Result Sets MARS see msdn. Consider reading up on Disadvantages of MARS too stackoverflow. In most cases, the error in question is caused by BAD CODE within the calling application. Where will likely solve the problem. Smells of a hack You can use the ToList method before the return statement.

Kisame 1, 1 13 The answer to the question is always to use ToList. Are there any downsides to this? If you have k rows I doubt this can be good. MartinMazzaDawsonYou really need K records at once query execution?? Name ; foreach Project project in user. Name ; foreach Task task in project. Subject ; foreach Message message in task. Despertar 13k 5 51 This is the best solution if your application otherwise does't require MARS. Here is a working connection string for someone who needs reference.

Yang Zhang 2, 1 21 Enabling MARS is a workaround, NOT a solution to the problem. From the MARS Documentation page: You can refactor your above two queries into one like this: StateChangeDate ; I also noticed you're calling functions like FormattedAccountNumber and FormattedRecordNumber in the queries.

James Alexander 2, 8 32 If you want you can refactor the query you're performing to get the DateLastUpdated directy into your Select projection for the Accounts Report query and get the desired effect without the error.

How can I refactor the query.

In my case I got same exception for below query. Ziggler 1 11 Isaac Muturi 36 3. In addition to Ladislav Mrnka's answer: Alexander Troshchenko 7. Michael Freidgeim 8, 4 55 Pranesh Janarthanan Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. In it, you'll get: The week's top questions and answers Important community announcements Questions that need answers. Stack Overflow works best with JavaScript enabled. I have had this error so many times now MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3.

Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,1 stars - 427 reviews
inserted by FC2 system