locked
db.executereader RRS feed

  • Question

  • User-1080261320 posted

    hi there ,

    I have this part of code and I  using entllib 5 : 

     

     

     Database DB = DatabaseFactory.CreateDatabase("Cs");
    
            using (IDataReader Reader = DB.ExecuteReader("select"))
            {
                GridView_Video_Download.DataSource = Reader;
                GridView_Video_Download.DataBind();
            }


     

     

     

     

    and I get this error : Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

    is there anybody help me ?

    
    

     

    Monday, October 25, 2010 8:18 AM

Answers

  • User198125801 posted

    You can't databind an IDataReader. You must first read the data from your Reader object into some kind of collection like Arraylist, List<>, Hashtable etc. 

    Then once the data is in the list, you databind the list to the gridview, not the reader.

    hope this helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 25, 2010 8:46 AM