using SQLDataReader more than once?

  • Thread starter Thread starter Mitch
  • Start date Start date
M

Mitch

I'm an ADO.NET newbie so bear with me. I've created and opened a
SqlDataReader against my MSSQL Server database just fine. The problem is
that I can't seem clone the data in the reader so that I can use it in 2
separate procs. The only other alternative is to instantiate 2 separate
SqlDataReaders and make two database calls, but this seems very inelegant.
There must be a better way....
 
Hi Mitch,

AFAIK only one datareader per connection can be active at the same time.
So, you will have to create not only another reader but also another
connection to use two of them at the same time.
 
Mitch said:
I'm an ADO.NET newbie so bear with me. I've created and opened a
SqlDataReader against my MSSQL Server database just fine. The problem is
that I can't seem clone the data in the reader so that I can use it in 2
separate procs. The only other alternative is to instantiate 2 separate
SqlDataReaders and make two database calls, but this seems very inelegant.
There must be a better way....

This is what the DataTable is for.

Use the DataReader to fill a DataTable (using a DataAdapter).

The DataTable can be shared, copied, remoted, saved, updated, merged, etc.

David
 
MARS(Multiple Active Results Sets)!
ado.net in .net framework 2.0 will support more than one opened datareader
on one connection instance
 
Back
Top