What is the easiest way to assign rows from Reader to a list object?

  • Thread starter Thread starter Jerry H.
  • Start date Start date
J

Jerry H.

What's the fastest/easiest way to assign the result set of a Reader to
the Datasource/Datamember of a Datagrid?

I know I could "For...Each" through the Reader's set, but I'm wonder if
there's a quicker way to pull it off.
 
If you have a ASP.NET Grid, you can just set the DataSource to
Command.ExecuteReader();

Otherwise, if you must walk it, use while(Reader.Read()){

}

Readers are streams essentially so you have to move through them.. with the
way ASP.NET's binding works, it will do the walking for you if you bind to
it, but it's still working through the data. If you are in Winforms, you
need to do it yourself and honestly, it's pretty simple to do.
 
Back
Top