Should I close a datareader returned using daab?

H

hansiman

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
 
K

Kevin Spencer

Well, he wants to make sure that he closes his Connection as well.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
S

Scott Allen

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
 
K

Kevin Spencer

I try not to assume anything.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 

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

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top