Hi all,

According the MSDN documentation on the SqlDataReader.Close method, it says
that:

The Close method fills in the values for output parameters, return values
and RecordsAffected, increasing the amount of time it takes to close a
SqlDataReader....

Is that mean before I can retrieve the value of stored procedure output
parameters, I should call the SqlDataReader.Close method? But in some sample
code I found on the web, it reads the output parameters before calling the
Close method?

Which is more appropriate?

Thanks for help!


Best Regards,
Tony

Re: Question on SqlDataReader.Close by Miha

Miha
Mon May 02 15:28:06 CDT 2005

Hi,

AFAIK when you are returning records from stored procedure all records have
to be returned to get the output parameters values.
So, yes, Close will fetch all the remaining records and set parameter
values.
It doesn't make much difference since you will have to call Close anyway -
regardless if you want to read or not all records.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

<AESi@community.nospam> wrote in message
news:e$lUXczTFHA.3188@TK2MSFTNGP09.phx.gbl...
> Hi all,
>
> According the MSDN documentation on the SqlDataReader.Close method, it
> says
> that:
>
> The Close method fills in the values for output parameters, return values
> and RecordsAffected, increasing the amount of time it takes to close a
> SqlDataReader....
>
> Is that mean before I can retrieve the value of stored procedure output
> parameters, I should call the SqlDataReader.Close method? But in some
> sample
> code I found on the web, it reads the output parameters before calling the
> Close method?
>
> Which is more appropriate?
>
> Thanks for help!
>
>
> Best Regards,
> Tony
>
>



Re: Question on SqlDataReader.Close by v-kevy

v-kevy
Mon May 02 21:56:10 CDT 2005

Thanks for Miha's quick response.

Hi Tony,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know if we can get the
output parameters before calling SqlDataReader.Close method. If there is
any misunderstanding, please feel free to let me know.

As far as I know, we cannot do this. Because, before Close method is
called, the output parameter values are not get. So if you're trying to
retrieve the values, you will get a null reference.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Re: Question on SqlDataReader.Close by AESi

AESi
Tue May 03 21:10:23 CDT 2005

Thanks for your help!

Regards,
Tony


"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:SCGrmu4TFHA.3052@TK2MSFTNGXA01.phx.gbl...
> Thanks for Miha's quick response.
>
> Hi Tony,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need to know if we can get the
> output parameters before calling SqlDataReader.Close method. If there is
> any misunderstanding, please feel free to let me know.
>
> As far as I know, we cannot do this. Because, before Close method is
> called, the output parameter values are not get. So if you're trying to
> retrieve the values, you will get a null reference.
>
> HTH.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



Re: Question on SqlDataReader.Close by v-kevy

v-kevy
Wed May 04 00:45:14 CDT 2005

You're welcome, Tony.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."