William
Thu Aug 04 18:17:49 CDT 2005
I agree, Using is very handy for local instantiation/tear-down (even in
VB.NET 2.0).
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uBliSkTmFHA.2916@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> "William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
> news:%23jheoJSmFHA.2860@TK2MSFTNGP15.phx.gbl...
>> Oh, I can't think of more than these reasons:
>> 1) Connections are a precious resource. Getting them closed quickly
>> (when they can be) is good for scalability
>
> Point 1. and 3.: Perhaps, but better practise is to use a try/finally (or
> C#'s using) block to open and close the connection. Furthermore, you
> normally do more than just one operation when connection is open so it
> won't help much.
>
>> 2) Consistency. All of the Command execute functions that require open
>> connections should have a CommandBehavior.CloseConnection available.
>
> Personally I don't need them as I am always explicitely opening and
> closing connections.
>
>> 3) Too many folks complain about overflowing connection pools look to
>> the ExecuteReader as the cause--it could be elsewhere. Setting CBCC makes
>> it easier to manage connections.
>>
>> Just because the enumeration is there does not mean you have to set it.
>
> Right.
>
>> There are valid reasons not to close the connection (as you expect to use
>> it again in the same function or you're working with a transaction...)
>
> Sure. I just think that nothing beats explicit open and close and nothing
> won't protect you from forgetting to close it even if that parameter
> exists.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> www.rthand.com
> Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
> SLODUG - Slovene Developer Users Group www.codezone-si.info
>
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com/blog/billva
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> __________________________________
>>
>> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
>> news:OQVgooMmFHA.3304@tk2msftngp13.phx.gbl...
>>>I am also curious. Why it should?
>>>
>>> --
>>> Miha Markic [MVP C#] - RightHand .NET consulting & development
>>> www.rthand.com
>>> Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
>>> SLODUG - Slovene Developer Users Group www.codezone-si.info
>>>
>>> "William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
>>> news:e5ONr2GmFHA.320@TK2MSFTNGP09.phx.gbl...
>>>> No it doesn't and it SHOULD (IMHO).
>>>>
>>>>
>>>> --
>>>> ____________________________________
>>>> William (Bill) Vaughn
>>>> Author, Mentor, Consultant
>>>> Microsoft MVP
>>>> www.betav.com/blog/billva
>>>> www.betav.com
>>>> Please reply only to the newsgroup so that others can benefit.
>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>> rights.
>>>> __________________________________
>>>>
>>>> "Sahil Malik [MVP]" <contactmethrumyblog@nospam.com> wrote in message
>>>> news:e$V2EoGmFHA.2860@TK2MSFTNGP15.phx.gbl...
>>>>> No it doesn't.
>>>>>
>>>>> --
>>>>>
>>>>> - Sahil Malik [MVP]
>>>>> ADO.NET 2.0 book -
>>>>>
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
>>>>> -------------------------------------------------------------------------------------------
>>>>>
>>>>> "WebBuilder451" <WebBuilder451@discussions.microsoft.com> wrote in
>>>>> message news:3D41865C-680D-4A70-9999-9A9BD8C5AECD@microsoft.com...
>>>>>> does the cmd.ExecuteScalar() auto close the connection the same as
>>>>>> RxecuteReader(commandbehavior.CloseConnection)?
>>>>>>
>>>>>> --
>>>>>> thanks (as always)
>>>>>> some day i''m gona pay this forum back for all the help i''m getting
>>>>>> kes
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>