SqlDataReader from DataSet (DataTable)

  • Thread starter Thread starter Frank Uray
  • Start date Start date
F

Frank Uray

Hi all

I have a DataSet with one table filled.
From this DataSet (DataTable), I need to create a SqlDataReader.

Does anybody knows how to do this ?
Is it possible ??

Thanks for any help.

Regards
Frank
 
Frank said:
I have a DataSet with one table filled.
From this DataSet (DataTable), I need to create a SqlDataReader.

Does anybody knows how to do this ?
Is it possible ??

Both DataSet and DataTable expose a method CreateDataReader which
creates a DataTableReader. I think that is the closest you get to an
SqlDataReader.
 
Hi Martin

Thank you for your answer.

I just have tried to use this,
but there is no way to convert DataReader to SqlDataReader ... :-((

Regards
Frank
 
Frank said:
I just have tried to use this,
but there is no way to convert DataReader to SqlDataReader ... :-((

As I said, DataTableReader is the closest you get.

DataTableReader and SqlDataReader have a common base class,
DbDataReader. Depending on your needs you might be able to use that type
for your variables and that way handle both SqlDataReader and
DataTableReader with the same code.
 
Frank said:
I just have tried to use this,
but there is no way to convert DataReader to SqlDataReader ... :-((

A SqlDataReader reads data over the network in a SQLServer specific
format.

DataTableReader reads data from a .NET in memory data structure.

It is no surprise that you can not convert a DataTableReader to
a SqlDataReader.

Arne
 
Back
Top