Is it possible to get a DataReader object from a DataSet/DataTable ? If so
would it
be disconnected ? in other words could I return a populated DataReader
object from a class that contains a DataSet ?

Re: DataSet -> DataReader by Miha

Miha
Fri Feb 20 08:41:12 CST 2004

Hi Dave,

Huh?
DataReader is just a sort of forward only readonly cursor.
Why would you need a DataReader from DataSet?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Dave Cook" <nospam@nospam.com> wrote in message
news:uwob2t79DHA.3900@tk2msftngp13.phx.gbl...
> Is it possible to get a DataReader object from a DataSet/DataTable ? If
so
> would it
> be disconnected ? in other words could I return a populated DataReader
> object from a class that contains a DataSet ?
>
>



Re: DataSet -> DataReader by Dave

Dave
Fri Feb 20 09:00:49 CST 2004

Hi Miha

I have written a collection class that returns data from a database table.
I would like to add a number of methods to the class that will also return
the data in a variety of usefull formats as the data will be used in a
variety of ways by different applications.

Some of the methods I have so far are:

SelectAllAsDataSet
SelectAllAsDataTable
SelectAllAsDataView
SelectAllAsXML

I would like to also be able to SelectAllAsDataReader. As all the above
methods use the DataSet object, I create the DataSet in the constructor. I
was hoping to derive the DataReader from the existing DataSet rather than
populating both objects as the table could potentially be quite large.

Since looking more into it, i am not sure i can return a DataReader object
from my class as the DataReader requires a permanent connection to the DB
for the life of the object.

If you have any ideas on this I would be gratefull.

Regards

Dave.


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:#mZCU#79DHA.1948@TK2MSFTNGP12.phx.gbl...
> Hi Dave,
>
> Huh?
> DataReader is just a sort of forward only readonly cursor.
> Why would you need a DataReader from DataSet?
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software development
> miha at rthand com
> www.rthand.com
>
> "Dave Cook" <nospam@nospam.com> wrote in message
> news:uwob2t79DHA.3900@tk2msftngp13.phx.gbl...
> > Is it possible to get a DataReader object from a DataSet/DataTable ? If
> so
> > would it
> > be disconnected ? in other words could I return a populated DataReader
> > object from a class that contains a DataSet ?
> >
> >
>
>



Re: DataSet -> DataReader by Miha

Miha
Fri Feb 20 09:38:15 CST 2004

Hi Dave,

You will have to implement IDataReader interface in a class that behaves
like datareader .
However, I still can't see where it might be useful.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Dave Cook" <nospam@nospam.com> wrote in message
news:ue4iOI89DHA.2524@TK2MSFTNGP11.phx.gbl...
> Hi Miha
>
> I have written a collection class that returns data from a database table.
> I would like to add a number of methods to the class that will also return
> the data in a variety of usefull formats as the data will be used in a
> variety of ways by different applications.
>
> Some of the methods I have so far are:
>
> SelectAllAsDataSet
> SelectAllAsDataTable
> SelectAllAsDataView
> SelectAllAsXML
>
> I would like to also be able to SelectAllAsDataReader. As all the above
> methods use the DataSet object, I create the DataSet in the constructor.
I
> was hoping to derive the DataReader from the existing DataSet rather than
> populating both objects as the table could potentially be quite large.
>
> Since looking more into it, i am not sure i can return a DataReader object
> from my class as the DataReader requires a permanent connection to the DB
> for the life of the object.
>
> If you have any ideas on this I would be gratefull.
>
> Regards
>
> Dave.
>
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:#mZCU#79DHA.1948@TK2MSFTNGP12.phx.gbl...
> > Hi Dave,
> >
> > Huh?
> > DataReader is just a sort of forward only readonly cursor.
> > Why would you need a DataReader from DataSet?
> >
> > --
> > Miha Markic [MVP C#] - RightHand .NET consulting & software development
> > miha at rthand com
> > www.rthand.com
> >
> > "Dave Cook" <nospam@nospam.com> wrote in message
> > news:uwob2t79DHA.3900@tk2msftngp13.phx.gbl...
> > > Is it possible to get a DataReader object from a DataSet/DataTable ?
If
> > so
> > > would it
> > > be disconnected ? in other words could I return a populated DataReader
> > > object from a class that contains a DataSet ?
> > >
> > >
> >
> >
>
>



Re: DataSet -> DataReader by Dave

Dave
Fri Feb 20 10:01:15 CST 2004

Hi Miha

I was thinking that a DataView would be handy for populating DataGrids etc
and a DataReader would provide better performance for populating ComboBoxes.

Am I wrong ?

As I may have mentioned earlier the the class will be shared and and used in
a variety of ways.



"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:eSIQ3e89DHA.2184@TK2MSFTNGP09.phx.gbl...
> Hi Dave,
>
> You will have to implement IDataReader interface in a class that behaves
> like datareader .
> However, I still can't see where it might be useful.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software development
> miha at rthand com
> www.rthand.com
>
> "Dave Cook" <nospam@nospam.com> wrote in message
> news:ue4iOI89DHA.2524@TK2MSFTNGP11.phx.gbl...
> > Hi Miha
> >
> > I have written a collection class that returns data from a database
table.
> > I would like to add a number of methods to the class that will also
return
> > the data in a variety of usefull formats as the data will be used in a
> > variety of ways by different applications.
> >
> > Some of the methods I have so far are:
> >
> > SelectAllAsDataSet
> > SelectAllAsDataTable
> > SelectAllAsDataView
> > SelectAllAsXML
> >
> > I would like to also be able to SelectAllAsDataReader. As all the
above
> > methods use the DataSet object, I create the DataSet in the constructor.
> I
> > was hoping to derive the DataReader from the existing DataSet rather
than
> > populating both objects as the table could potentially be quite large.
> >
> > Since looking more into it, i am not sure i can return a DataReader
object
> > from my class as the DataReader requires a permanent connection to the
DB
> > for the life of the object.
> >
> > If you have any ideas on this I would be gratefull.
> >
> > Regards
> >
> > Dave.
> >
> >
> > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> > news:#mZCU#79DHA.1948@TK2MSFTNGP12.phx.gbl...
> > > Hi Dave,
> > >
> > > Huh?
> > > DataReader is just a sort of forward only readonly cursor.
> > > Why would you need a DataReader from DataSet?
> > >
> > > --
> > > Miha Markic [MVP C#] - RightHand .NET consulting & software
development
> > > miha at rthand com
> > > www.rthand.com
> > >
> > > "Dave Cook" <nospam@nospam.com> wrote in message
> > > news:uwob2t79DHA.3900@tk2msftngp13.phx.gbl...
> > > > Is it possible to get a DataReader object from a DataSet/DataTable ?
> If
> > > so
> > > > would it
> > > > be disconnected ? in other words could I return a populated
DataReader
> > > > object from a class that contains a DataSet ?
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: DataSet -> DataReader by Miha

Miha
Fri Feb 20 10:11:56 CST 2004

Hi Dave,

"Dave Cook" <nospam@nospam.com> wrote in message
news:u%23xa$p89DHA.1268@TK2MSFTNGP12.phx.gbl...
> Hi Miha
>
> I was thinking that a DataView would be handy for populating DataGrids etc
> and a DataReader would provide better performance for populating
ComboBoxes.

Yes and no. DataReader might be used when retrieving data from database and
the data doesn't need to be persisted in DataTable.
If you already have data in datatable then DataReader is meaningless and
probably causes overhead.

> Am I wrong ?
>
> As I may have mentioned earlier the the class will be shared and and used
in
> a variety of ways.

Since your data is already in memory just use DataTable (when DataTable is
bind - in reallity DataTable.DefaultView is bound) or DataView as
datasource.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com



Re: DataSet -> DataReader by Dave

Dave
Fri Feb 20 10:19:20 CST 2004

of course, thanks for your help Miha.


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:#Qt$Ax89DHA.1504@TK2MSFTNGP12.phx.gbl...
> Hi Dave,
>
> "Dave Cook" <nospam@nospam.com> wrote in message
> news:u%23xa$p89DHA.1268@TK2MSFTNGP12.phx.gbl...
> > Hi Miha
> >
> > I was thinking that a DataView would be handy for populating DataGrids
etc
> > and a DataReader would provide better performance for populating
> ComboBoxes.
>
> Yes and no. DataReader might be used when retrieving data from database
and
> the data doesn't need to be persisted in DataTable.
> If you already have data in datatable then DataReader is meaningless and
> probably causes overhead.
>
> > Am I wrong ?
> >
> > As I may have mentioned earlier the the class will be shared and and
used
> in
> > a variety of ways.
>
> Since your data is already in memory just use DataTable (when DataTable is
> bind - in reallity DataTable.DefaultView is bound) or DataView as
> datasource.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software development
> miha at rthand com
> www.rthand.com
>
>