locked
Getting Datareader already open error. RRS feed

  • Question

  • Hi,

    I am doing a windows application project. I am trying to handle my data using a single command object. I use SqlDataAdapter to fill my datatables. Now I get this error "There is already an open DataReader associated with this Command which must be closed first." As I reckon, I have not used DataReaders anywhere...?

    EDIT: This happens while trying to fill a datatable

    I am a bundle of mistakes intertwined together with good intentions
    Friday, January 2, 2009 8:42 PM

All replies

  • Make sure that you close any DataReader after you finish to work with it. By default you will not be able to open more than one DataReader against each connection unless you set MARS (Multiple Active Result Set) option in your connection string to support it. Even for loading DataTable provider uses DataReader, so if your application already has opened reader, filling DataTable will fail.
    Val Mazur (MVP) http://www.xporttools.net
    Monday, January 5, 2009 11:20 AM
  • How to close one when I have not used one anywhere?
    I am a bundle of mistakes intertwined together with good intentions
    Tuesday, January 6, 2009 4:50 AM
  • Can you provide the code?
    Tuesday, January 6, 2009 6:18 AM
    Answerer