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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Possible memory leak in SQLDataReader(). 4
Need More ADO Suggestions 23
SqlDataReaded closing unexpectedly 3
SqlDataReader SLOW 6
Timeout Error 1
about performance 2
Connet to SQL Server? 7
Reusing SqlCommand 8

Back
Top