> Having MS manage the connection = resource leak?
>
> I don't follow you -- how is closing a connection (and it not being
> really closed on the server end) sloppy programming? Unless you're
> refering the MS programming?
No, *not* closing a connection (and relying on finalization) is sloppy
programming.
> Forcing developers to perform connection management does OPEN the
> door for sloppy programming (a door in which we should have the
> option to keep closed) -- yes I agree with that and exactly why MS
> should provide an option to deal with it automatically and
> efficiently -- rather than the inconsistant approach they use now.
[What inconsistent approach?]
There is simply no way of automagically closing (or rather releasing,
see below) connections efficiently in .NET Or Java as of today, due to
the unmanaged nature of these resouces. You can do it either explicitly
or rely on (read: hope for) finalization. The latter option is just
plain bad.
> Rather than the current method to try to close a connection:
> close the datareader
[quoted text clipped - 3 lines]
> and for good measure set it to Nothing
> and if you're really thorough, then initial GS (garbage collection)
Note that this is all boilerplate code that can be easily abstracted
away. It's just a matter of application architecture.
> Then and only then, can you be pretty sure your connection is closed.
> That's a LOT of work to ensure a connection gets closed -- and since
> it is recommended to close connections ASAP, the developer's are
> encouraged to open/close many many many times -- opening a closing
> connections A LOT is also not efficient.
Welcome to the world of connection pooling. A proper ADO.NET data
provider will not simply close and reestablish physical connections,
but pool them. In this context, "close" means actually "release and
return to the pool", whereas "open" means "obtain from the pool".
Cheers,

Signature
http://www.joergjooss.de
mailto:news-reply@joergjooss.de