Home All Groups Group Topic Archive Search About

SqlDataAdapter: Connection closed on exception?

Author
4 Nov 2005 12:05 PM
Pieter
Hi,

An SqlDataAdapter always opens its Conection and closes it automaticly. But
does it Close the connection also when an exception occured?

I tried to test it, and the connection was everytime closes, but I don't
knwo if this would happen with every type of exception... I googled around
for it but didn't find anything.

Anybody could clear this out,

Thanks,

Pieter

Author
4 Nov 2005 1:17 PM
Miha Markic [MVP C#]
Yes, it does.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Pieter" <pietercou***@hotmail.com> wrote in message
news:%23zVRFgT4FHA.3312@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> An SqlDataAdapter always opens its Conection and closes it automaticly.
> But does it Close the connection also when an exception occured?
>
> I tried to test it, and the connection was everytime closes, but I don't
> knwo if this would happen with every type of exception... I googled around
> for it but didn't find anything.
>
> Anybody could clear this out,
>
> Thanks,
>
> Pieter
>
Author
4 Nov 2005 1:37 PM
S.M. Altaf [MVP]
You could work on the safe side and place your connection closing code in
the Finally block, since that gets run anyways.

--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com


Show quote
"Pieter" <pietercou***@hotmail.com> wrote in message
news:%23zVRFgT4FHA.3312@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> An SqlDataAdapter always opens its Conection and closes it automaticly.
> But does it Close the connection also when an exception occured?
>
> I tried to test it, and the connection was everytime closes, but I don't
> knwo if this would happen with every type of exception... I googled around
> for it but didn't find anything.
>
> Anybody could clear this out,
>
> Thanks,
>
> Pieter
>

AddThis Social Bookmark Button