William
Sat Jul 24 21:28:09 CDT 2004
Ok, sorry about that. My reader had it listed first but that explains the
RE:
--
W.G. Ryan MVP Windows - Embedded
Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
"Scott M." <s-mar@nospam.nospam> wrote in message
news:enVs5sdcEHA.2840@TK2MSFTNGP11.phx.gbl...
> Actually, I didn't ask a question, John did.
>
>
> "William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
> news:%23jnRBDccEHA.2812@TK2MSFTNGP11.phx.gbl...
> > Hi Scott:
> >
> > I see the others have answered your question but I'd like to mention the
> new
> > stuff in ADO.NET 2.0 that addresses this issue. Also, you could create
a
> > Subclassed grid, simple inherit from DataGird and you can come up with
> your
> > own method to load the grid from a Reader if you really need this
> > functionality. You're going to have to bind it to a
> > datatable/dataset/dataview or some other IList object (Actually my
memory
> is
> > foggy now but I think you can bind to anything that implements IList) or
> > strongly typed collection. So you can build a datatable from the reader
or
> > build a collection from it and bind to either of those but it'll take
some
> > work. Since Readers work best for read only scenarios and grids are
> usually
> > used for editing in the winforms context -probably not a big need for
this
> > whereas on the web there is b/c it's usually a read only scenario (and
> > although you can 'edit' in a web grid, the underlying story is a bit
> > different which makes the reader a nice choice)
> >
> > In ASP.NET you are allowed to bind to a reader, actually
> > dataGrid.DataSource = myCommand.ExecuteReader(); It handles the
> > while(reader.Read()) for you and builds a datatable. It's a clunky
> > implementation though b/c the reader may not have any rows so you have
to
> > put in an extra check to verify the grid will have something in it.
> >
> > In ADO.NET 2.0 you can do something similar with the DataTable's .Load
> > method. You can load a DataTable from a DataReader WITHOUT reading
> through
> > it. So assuming I just called ExecuteReader on a reader named dr I
could
> to
> > this:
> >
> > DataTable dt = new DataTable("TableFromReader");
> > dt.Lead(dr); //Didn't have to do anything other than call ExecuteReader
> > before this somewhere
> > DataGrid1.DataSource = dt; //Will work in Winforms!
> >
> > You can also do the reverse, get a Reader from a DataTable!!!!!
> >
> > The DataTable has a GetReader method , which will give you a DataReader
> > from a DataTable
> > I have some examples of all of this here
> >
http://www.knowdotnet.com/articles/miscadonet.html
> > or here
> >
http://msmvps.com/williamryan/archive/2004/07/14/10090.aspx
> >
> > --
> >
> > --
> >
> > W.G. Ryan, eMVP
> >
> > Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
> > Let Microsoft know!
> >
http://www.devbuzz.com |
http://www.knowdotnet.com
> > https://www.windowsembeddedeval.com/community/newsgroups
> > "John Dann" <news@prodata.co.uk> wrote in message
> > news:dc35g0d55q1sb8q09nhn7rtq4g8kkvguqf@4ax.com...
> > > Is there a Winforms grid to which I can readily bind a datareader
> > > (purely for read-only visualisation of the datareader data and using
> > > the 1.1 framework)? Or is this in some way not regarded as a
> > > legitimate use for the datareader?
> > >
> > > JGD
> >
> >
>
>