locked
There is already an open DataReader associated with this Connection which must be closed first. RRS feed

  • Question

  • There is already an open DataReader associated with this Connection which must be closed first.

    using Entity Framework+My Sql


    Port80
    • Moved by edhickey Tuesday, August 23, 2011 6:57 PM (From:.NET 4: Windows Workflow Foundation)
    Tuesday, August 23, 2011 5:38 PM

Answers

  • Hi,

    make sure you don't have nested forech loops. If you do, use ToList on the outer loop to retrieve all the data so you won't have two concurrent readers.

    Thank you,

    Julia


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, August 23, 2011 8:29 PM

All replies

  •  

    Please post the code and where the exception happens.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, August 23, 2011 8:17 PM
  • Hi,

    make sure you don't have nested forech loops. If you do, use ToList on the outer loop to retrieve all the data so you won't have two concurrent readers.

    Thank you,

    Julia


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, August 23, 2011 8:29 PM
  • Hello,

    Entity Framework and ADO.NET weren't the same one. In addition, did Julia's suggestion help you solve your question? If not, please provide the detailed code snippet in your reply.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 25, 2011 8:47 AM
  • We've not heard from you a couple of time. I closed this case temporarily. Please feel free to let us know if you need further support.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 29, 2011 5:23 AM