Tuesday, March 13, 2012

Should I close a datareader returned using daab?

I'm unsure if I should call the close method (dr.Close()) of the
sqldatareader after the following code:
Dim dr As SqlDataReader
= SqlHelper.ExecuteReader(strConn,
CommandType.StoredProcedure, "SPROC", arParms)
If dr.Read Then
m_strValue = dr("Value")
End If
/MYes you should.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"hansiman" <hansi@.hotmail.com> wrote in message
news:52v181psppa9cebrur1vff8oaqv865dvqv@.
4ax.com...
> I'm unsure if I should call the close method (dr.Close()) of the
> sqldatareader after the following code:
> Dim dr As SqlDataReader
> = SqlHelper.ExecuteReader(strConn,
> CommandType.StoredProcedure, "SPROC", arParms)
> If dr.Read Then
> m_strValue = dr("Value")
> End If
>
> /M
>
Thanks. And I don't need to do any other cleaning?
On Tue, 10 May 2005 11:31:16 -0700, "Steve C. Orr [MVP, MCSD]"
<Steve@.Orr.net> wrote:

>Yes you should.
No, that's all.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"hansiman" <hansi@.hotmail.com> wrote in message
news:st0281pkmlpafd2hbf9rrssb45alj0vlbd@.
4ax.com...
> Thanks. And I don't need to do any other cleaning?
> On Tue, 10 May 2005 11:31:16 -0700, "Steve C. Orr [MVP, MCSD]"
> <Steve@.Orr.net> wrote:
>
>
Well, he wants to make sure that he closes his Connection as well.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:eO1EUwZVFHA.2960@.TK2MSFTNGP15.phx.gbl...
> No, that's all.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "hansiman" <hansi@.hotmail.com> wrote in message
> news:st0281pkmlpafd2hbf9rrssb45alj0vlbd@.
4ax.com...
>
isn't the connection handled by the daab?
On Tue, 10 May 2005 16:57:27 -0400, "Kevin Spencer"
<kevin@.DIESPAMMERSDIEtakempis.com> wrote:

>Well, he wants to make sure that he closes his Connection as well.
I'm pretty sure the DAAB uses CommandBehavior.CloseConnection as an
argument to ExecuteReader on the command object, meaning when you
close the reader the connection will be closed also
Scott
http://www.OdeToCode.com/blogs/scott/
.
On Tue, 10 May 2005 20:26:52 +0200, hansiman <hansi@.hotmail.com>
wrote:

>I'm unsure if I should call the close method (dr.Close()) of the
>sqldatareader after the following code:
>Dim dr As SqlDataReader
> = SqlHelper.ExecuteReader(strConn,
> CommandType.StoredProcedure, "SPROC", arParms)
> If dr.Read Then
> m_strValue = dr("Value")
> End If
>
>/M
I try not to assume anything.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"hansiman" <hansi@.hotmail.com> wrote in message
news:h7c2815mju0fcjj2nhj2drrvi4l539gt1r@.
4ax.com...
> isn't the connection handled by the daab?
> On Tue, 10 May 2005 16:57:27 -0400, "Kevin Spencer"
> <kevin@.DIESPAMMERSDIEtakempis.com> wrote:
>
>

0 comments:

Post a Comment