473,383 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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
/M

Nov 19 '05 #1
7 1242
Yes you should.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"hansiman" <ha***@hotmail.com> wrote in message
news:52********************************@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

Nov 19 '05 #2
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]"
<St***@Orr.net> wrote:
Yes you should.


Nov 19 '05 #3
No, that's all.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"hansiman" <ha***@hotmail.com> wrote in message
news:st********************************@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]"
<St***@Orr.net> wrote:
Yes you should.

Nov 19 '05 #4
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.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eO**************@TK2MSFTNGP15.phx.gbl...
No, that's all.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"hansiman" <ha***@hotmail.com> wrote in message
news:st********************************@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]"
<St***@Orr.net> wrote:
Yes you should.


Nov 19 '05 #5
isn't the connection handled by the daab?

On Tue, 10 May 2005 16:57:27 -0400, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> wrote:
Well, he wants to make sure that he closes his Connection as well.


Nov 19 '05 #6
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 <ha***@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


Nov 19 '05 #7
I try not to assume anything.

--
HTH,

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

"hansiman" <ha***@hotmail.com> wrote in message
news:h7********************************@4ax.com...
isn't the connection handled by the daab?

On Tue, 10 May 2005 16:57:27 -0400, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> wrote:
Well, he wants to make sure that he closes his Connection as well.

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
3
by: sam | last post by:
Hello group, I have a function which is used to initiate sqlDataReader object. I was trying to invoke the close method on the DataReader object but cant really do that as the function returns a...
1
by: huzz | last post by:
I have a method that gets sqldatareader as shown below.. my question is how do i close the sqlconnection (objConn) object within this method? If i put the objconn.Close(); after the return then i...
5
by: Joel Reinford | last post by:
I am attempting to verify whether a datareader is closed by calling the databind on a control. for example (fake code) Dim rdr as SqlDataReader rdr = mycommand.executeReader... ...
3
by: bdwgarth | last post by:
I am trying to open a new web page for each item returned by the DataReader. I am using JavaScript to open each new window, and using a session variable to pass the DataReader Item value to the...
2
by: David Beaven | last post by:
I am creating an aspx page to show (i.e. read only) hundreds or probably thousands of items from two database queries. The user may of course only want to read one or two pages worth. I have (I...
5
by: Varangian | last post by:
Hello there people, I'm having some kind of problem. I have a function that returns a datareader. At some point using the application I get an error "Unspecified error" (ssssoooo helpful) :). I...
17
by: Alan Silver | last post by:
Hello, I have a generic method in a utility class that grabs an sqldatareader and returns it. Due to the fact that (AFAIK), you can't close the database connection before you've read the data,...
3
by: db.guru | last post by:
Hello, I was wondering what the best practices are as far as how many connections one should use for a data-driven app. Here's my situation: I have a business object that I load data into, this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.