Ian/Dan,

>>> "Kevin E. Kenny" <[EMAIL PROTECTED]> wrote:
>>> > Where there is a Close() it will invariably call Dispose().
>>>
>>> For SqlConnection that's not quite true.  Close() doesn't call
>>Dispose().
>>> But Dispose() does call Close().  Dispose() also clears the 
>>connection string.
>>> --
>>> Ian Griffiths
>>> DevelopMentor

Yes that's correct I appologise if I was being too sweeping in my reply.

<Slightly OT> And then you also have the odd ball cases where some
classes like the FileStream class that have had their Dispose() methods
implemented with an explicit interface implementation and you have to
cast the object to IDisposable before calling Dispose(). But the using()
statement generally sorts this kind of thing out for you.

I think you really have to approach each class on a case by case basis.
A quick scan with ILDASM doesn't hurt if the docs aren't too clear.

>>> Dispose() also clears the connection string.
>>Does that have an affect on the connection pool?
>>Dan Green

The connection is released back to pool in both cases if connection
pooling is enabled (default). You should also Dispose()/Close() broken
connections as well.

The section 'Connection Removal' is useful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide
/html/cpconconnectionpoolingforsqlservernetdataprovider.asp?frame=true

Also the section titled 'Connection Usage Patterns' provides another
helpful angle:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/h
tml/daag.asp

Kev
ps: appologies for the confusing mix of <from:> email addresses.

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