473,401 Members | 2,125 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,401 software developers and data experts.

Closing IDataReader

Hi,
In few places within my code
the business object pass IDataReader to the GUI.
Suddenly i noticed that nowhere in the code the IDataReader
is being closed.
Does the data binding operation closes the IDataReader?
If i didn't close it explicitly, the IDataReader remains open untill GC will
clean it?
Thanks.

Oct 5 '06 #1
2 1539

My suggestion is to never send an IDataReader to the presentation layer.

But you need to close it.

IDataReader idr = //Something to get it

try
{

//do something with it

}
finally
{
if(null!=idr)
{
idr.Close();
}
}
See my blog
http://sholliday.spaces.live.com/?_c...26ayear%3d2006

On using an IDataReader in the business logic layer, and passing a Custom
Collection to the Presentation Layer.

"???? ???????" <@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
Hi,
In few places within my code
the business object pass IDataReader to the GUI.
Suddenly i noticed that nowhere in the code the IDataReader
is being closed.
Does the data binding operation closes the IDataReader?
If i didn't close it explicitly, the IDataReader remains open untill GC
will
clean it?
Thanks.

Oct 5 '06 #2
Hi

essentially iterating the datareader will close it however, it's a good
practise to close it explicitly (for example if an error can occur)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"???? ???????" <@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
Hi,
In few places within my code
the business object pass IDataReader to the GUI.
Suddenly i noticed that nowhere in the code the IDataReader
is being closed.
Does the data binding operation closes the IDataReader?
If i didn't close it explicitly, the IDataReader remains open untill GC
will
clean it?
Thanks.

Oct 5 '06 #3

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

Similar topics

2
by: Vivek Sharma | last post by:
Hi There, can some one please clarify the difference between SQLDataReader and IDataReader? What are the advantages and disadvantages of each? Thanks Vivek
5
by: Gelios | last post by:
Hello All! I am going to crazy and feeling myself so stupid but I don't understand such behaviour. I have code: public int getNextAgentId() { Int32 agent_id = 0; IDataReader dr =...
4
by: Mahesh Kumar.R | last post by:
What is the difference between SqlDataReader and IDataReader ...? kindly with small example... Mahesh~
3
by: js | last post by:
Hi, I want to debug the return idatareader, how to print out some fields value? many thanks.
3
by: rockdale | last post by:
I am using Microsoft.Practices.Enterprise.Library When I use IDataReader I saw this line "It is the responsibility of the caller to close the connection and reader when finished." I was...
2
by: Larry R | last post by:
Whenever I try the following, the reader that is returned is always closed. What am I missing ? When I look at the reader in the ExecuteReader, it is fine. THen it gets closed on the returm. ...
0
by: rsdev | last post by:
Hi, I am new to ASP.NET and I am trying to build a CMS application using theBeerHouse SK. I am adapting the Datareader to collect information from an SQL database and send it to an HtmlHeader. ...
2
by: RP | last post by:
I saw a code in a class where IDataReader is used to retrieve result from query, even if only one column is to be retrieved. It uses a CommandObject with ExecuteReader but not using ExecuteScalar....
0
by: Andrus | last post by:
RDLDesigner report designer requires IDataReader for data access. To use it with Linq, I need to convert Linq projection to IDataReader. var db = new NorthwindContext(); var q = from c in...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.