Re: cloning IDbDataReader (SqlDataReader)

Marc Brooks <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
> I don't think I  understand what you're after.  If you need to get at the
> output parameters before you iterate through the results, perhaps you should
> consider sending them as the first resultset?

You're talking about doing two (or more) SELECT statements, he's
talking about doing stored procedures with output or retval
parameters.  That said, you can often code the latter in terms of the
former simply by placing a SELECT of the output values somewhere.

That said, the easiest thing for the OP to do is to go ahead and
iterate the IDbDataReader and inject the rows into a DataTable, then
hand that out as the return value (wrapped in a DataReader as needed).

The key to remember is that the IDbDataReader is effectively a
firehose that you need to suck empty before you get the rest of the
stuff on the TDS, so just copy it out as you can, then hand off the
collection you've built-up.

--
"One of the main causes of the fall of the Roman Empire was that,
lacking zero, they had no way to indicate successful termination of
their C programs." --Robert Firth

Marc C. Brooks
http://musingmarc.blogspot.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.