Re: cloning IDbDataReader (SqlDataReader)

"David L. Penton" <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
Output parameters are not available from a SQL Server stored procedure (i.e. batch) until all resultsets and processing are
completed.  No matter if you have not iterated any resultsets or not.

Peter, you will need to finish execution of your stored procedure.  If you need the count of records or whatever before binding, you
should look into binding to a DataSet or loading a custom collection.

  - David

Shawn Wildermuth wrote:
> 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?
>
> Thanks,
>
> Shawn Wildermuth
> http://adoguy.com
> C# MVP, MCSD.NET, Author and Speaker
>
> -----Original Message-----
> From: Discussion relating to the specifics of the C# and Managed C++
> languages [mailto:[email protected]] On Behalf Of Peter Osucha
> Sent: Wednesday, June 07, 2006 3:46 PM
> To: [email protected]
> Subject: [DOTNET-CX] cloning IDbDataReader (SqlDataReader)
>
> In VB6 days, there were times I'd call a SQL stored procedure which returned
> a recordset but also changed a stored procedure parameter that was marked as
> either 'OUTPUT' or 'INPUTOUTPUT'.  To do this but still access the recordset
> records, I normally ended up cloning the recordset returned so that I could
> close the ADO command object - and thereby immediately access the stored
> procedure OUTPUT parameters yet still have access to the recordset returned
> by the stored procedure.
>
> After reviewing the MSDN documentation, OUTPUT parameters cannot be
> retrieved until after closing a SqlDataReader object - but the SqlDataReader
> object doesn't support the ICloneable interface (though SqlCommand does).
> So it seems easy enough to fill a SqlDataReader object using
> cmd.ExecuteReader yet I can't access any stored procedure OUTPUT values
> until I close the reader.
>
> Perhaps the stored procedures need to be rethought but what could be done to
> allow access to the OUTPUT parameters but still have the SqlDataReader
> object to use?
>
> Peter

===================================
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.