473,395 Members | 1,613 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,395 software developers and data experts.

is a reader automaticaly disposed if the connection it is associated with is closed?

is a reader automaticaly disposed if the connection it is associated with is
closed?

what will happen if an app:

while true
open connection
open reader
close connection
end while
Sep 18 '07 #1
1 1150

There isn't much point in asking the question. Always close/dispose
your disposable objects. Always. :-)

If for purely educational reasons you want to know the answer of what
happens when you don't dispose a reader and instead dispose the
connection, you have to get more specific. The behavior could vary
depending on which reader--mssql, oledb, oracle, sybase, sqlite,
mysql, and on and on. I know for sure that the SQLite implementation
has a lot of code in it to handle this situation and will close
readers, but it's 'cause the author is extremely forgiving to bad
developers that don't close their disposable objects.

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.


On Tue, 18 Sep 2007 14:14:46 -0700, "Daniel"
<so*******************@yahoo.comwrote:
>is a reader automaticaly disposed if the connection it is associated with is
closed?

what will happen if an app:

while true
open connection
open reader
close connection
end while
Sep 18 '07 #2

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

Similar topics

17
by: Filip Strugar | last post by:
Considering that the BinaryWriter/BinaryReader object closes the underlaying stream upon being gc collected, is the following code correct, and if it is what is the reason preventing BinaryWriter...
1
by: juli jul | last post by:
Hello, I am using a reader in order to read query results: SqlDataReader rdr = null; SqlDataReader rdr_rows=null; this.conn.Open(); SqlCommand cmd = new SqlCommand("select name from...
1
by: Mike P | last post by:
I'm using 1 connection to open 3 separate data readers to read data into 3 data grids. However, when I try to use the 2nd reader it says that the first reader must be closed. So I use Close() to...
2
by: Patrick Olurotimi Ige | last post by:
Why do i get "Invalid attempt to FieldCount when reader is closed" Is the problem the way the datareader reads data as opposed to a dataset? When trying to compile this code:- Dim reader As...
1
by: sivam.solai | last post by:
Public Function GetTopLevelThreadName(ByVal ThreadID As Integer) As SqlDataReader Sp_Datasql = "WS_Get_TopLevelThreadName" SqlParam = New SqlParameter(0) {} Try SqlParam(0) = New...
8
by: Saurabh | last post by:
Hi, I am getting the below mentioned error when I try to update a table Exception: Unable to update Person records Exception : System.Data.SqlClient.SqlException: Timeout expired. The...
20
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL 2005. To use connection pooling and avoid the error "There is already an open DataReader associated with this Connection which must be closed first." , I understand...
1
by: Daniel | last post by:
is a reader automaticaly disposed if the connection it is associated with is closed? what will happen if an app: while true open connection open reader close connection end while
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.