I invoke Dispose() like crazy inside the DAL I wrote, and was wondering if
it was overkill.  Your comments reinforce to me that, no matter how much
people tell me "you don't have to Dispose everything under the sun," I am
doing the right thing by cleaning up after myself.

Francesco




>From: Brad Wilson <[EMAIL PROTECTED]>
>Reply-To: The DOTNET list will be retired 7/1/02
><[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: [DOTNET] ADO.NET and Dispose
>Date: Tue, 11 Jun 2002 07:40:10 -0600
>
>Chris Anderson wrote:
>
> > Basically..Am I going overkill on the Dispose methods?
>
>Not at all. If a class implements IDisposable, that means it wants to call
>Dispose the absolute moment you're through. In the case here, it means
>database connection resources are returned to the pool to be used by
>others.
>I believe (thought I have not tested) that if you weren't calling Dispose
>there, you would soon run out of connection resources and connections to
>the
>database would fail.
>
> > I can't find anything in the docs about it (just that Dispose should be
> > called if it exists, and you're finished with it) and the ADO.NET books
>I've
> > looked through rarely call Dispose at all (perhaps with the same
>reasoning
> > that error handling is rarely shown in books..to make the point of the
> > example clear)
>
>This would be a significantly damning statement about an ADO.net book that
>didn't call Dispose (or at least Close). Something like that should always,
>always be done.
>
>Brad
>
>--
>Read my web log at http://www.quality.nu/dotnetguy/
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to