Home All Groups Group Topic Archive Search About
Author
26 Jan 2006 9:30 PM
Vedanshu Mandvikar
Hi EveryOne,

What is the best approach for data access while developing applications
using Windows Forms ? Is it opening, working with and closing a new
SQLconnection and SQLcommand object everytime a DB access is needed , or
maintaining a single open connection/command object at the application level
( one for each user ) and then just reusing it again and again. The
connection string that the connection will use can be assumed to be static.

--
Vedanshu Mandvikar

Author
27 Jan 2006 12:04 AM
C.C. (aka Me)
It depends on what your requirements are.

If your user will be making a lot of changes/queries in a short amount of
time then it is probably better to keep the connection open.

If they perform a query and then process the datal locally for a while
before interacting with the DB again then it might be better to close it and
reopen when it as needed.

Keeping a connection open, when it is not going to be used for a while, is a
waste of server resources on the DB side.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Charles Cox
VC/VB/C# Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Show quote
"Vedanshu Mandvikar" <vedan***@gmail.com> wrote in message
news:2577EC48-2848-41D3-8221-B911A7FEB85D@microsoft.com...
> Hi EveryOne,
>
> What is the best approach for data access while developing applications
> using Windows Forms ? Is it opening, working with and closing a new
> SQLconnection and SQLcommand object everytime a DB access is needed , or
> maintaining a single open connection/command object at the application
> level
> ( one for each user ) and then just reusing it again and again. The
> connection string that the connection will use can be assumed to be
> static.
>
> --
> Vedanshu Mandvikar

AddThis Social Bookmark Button