Connecting Tech Pros Worldwide Forums | Help | Site Map

Closing IDataReader

יוני גולדברג
Guest
 
Posts: n/a
#1: Oct 5 '06
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.


sloan
Guest
 
Posts: n/a
#2: Oct 5 '06

re: Closing IDataReader



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:B54200F0-79A2-4BAB-A1B5-B42D0AF50755@microsoft.com...
Quote:
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
Quote:
clean it?
>
>
Thanks.
>

Teemu Keiski
Guest
 
Posts: n/a
#3: Oct 5 '06

re: Closing IDataReader


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:B54200F0-79A2-4BAB-A1B5-B42D0AF50755@microsoft.com...
Quote:
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.
>

Closed Thread