M
Matt C.
I'm writing a WinForms app, and trying to decide whether or not to leave the
connection object open permanently, or call .Open() and .Close() on it for
each db action. My current understanding says that there is no particular
importance in opening and closing the object because ADO.NET is going to
keep a db connection open anyway (so long as I am using the defaults for
conn pooling).
I see a lot of comments from MVPs insisting one should always use .Open()
and .Close() for each db request. I am not sure if these commenters are
unaware of the db connection being kept open anyway, or they are talking
about web apps only, or they have some further good reason for saying "open
late close early".
Does everyone agree that ADO.NET is going to keep a connection open
regardless of whether or not I use .Close() on the conn object? If so, is
there still an argument for explicitly closing the conn object inside a
WinForms app?
Matt
connection object open permanently, or call .Open() and .Close() on it for
each db action. My current understanding says that there is no particular
importance in opening and closing the object because ADO.NET is going to
keep a db connection open anyway (so long as I am using the defaults for
conn pooling).
I see a lot of comments from MVPs insisting one should always use .Open()
and .Close() for each db request. I am not sure if these commenters are
unaware of the db connection being kept open anyway, or they are talking
about web apps only, or they have some further good reason for saying "open
late close early".
Does everyone agree that ADO.NET is going to keep a connection open
regardless of whether or not I use .Close() on the conn object? If so, is
there still an argument for explicitly closing the conn object inside a
WinForms app?
Matt