There is already an open DataReader associated with this Command which must be closed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yogeshraj
    New Member
    • May 2013
    • 1

    There is already an open DataReader associated with this Command which must be closed

    I am using visual studio 2012 with SqlServer 2008.
    while developing a website, i used datareader
    when i wanted to use the datareader again for reading another table data from the same database, i get the error"There is already an open DataReader associated with this Command which must be closed first".
    I have used datareader.Clos e(), it does not help;
    I have used datareade.Dispo se(), this also does not help;
    I have also used using( Datareader ----) it was no help;
    I have also used try ( --- ) catch (SqlException)
    still i get the same error,
    Can any one help. I am stuck because i need to read data a number of times in this web site.
    any kind of help or alternative to read data from same database multilpe times will be appreciated.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I don't use .Net much so I probably can't answer the question but I know that whoever can answer your question won't be able to because you haven't shown us the code that produces the error.

    Comment

    • vijay6
      New Member
      • Mar 2010
      • 158

      #3
      Hey yogeshraj, datareader.Clos e() method should work.

      Comment

      • rajeshk
        New Member
        • May 2013
        • 2

        #4
        yogeshraj,
        You cant perform any operation with datareader result.if you want to perform any action with result then you have to use dataset and fetch result with foreach and perform action..

        Thanks & regards,
        rajeshk

        Comment

        Working...