Should I close a datareader returned using daab?

  • Thread starter Thread starter hansiman
  • Start date Start date
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
 
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.
 
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
 
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

Back
Top