Results 1 to 3 of 3

Thread: Fill a datagrid with a datareader ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    369

    Fill a datagrid with a datareader ?

    Hi,

    In VB.NET 2003.

    Is it possible to fill a datagrid with a datareader?


    Code:
    'This line works ..  data are correctly read.
    sqlDataReader = sqlCommand.ExecuteReader
    
    'This line crashes .. 
    grdGrid.DataSource = sqlDataReader
    I get the error:
    Error : Complex DataBinding accepts as a data source either an IList or an IListSource

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Fill a datagrid with a datareader ?

    That works with the WebForms DataGrid but not the WinForms version. You need to populate a DataTable and bind that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    369

    Re: Fill a datagrid with a datareader ?

    Ok thanks.

    That is what I did.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width