Keep a connection open or close for each request

A

Adrian Bezzina

I am wondering what the best use of the SQLConnection object is in a
WinForms application - to keep it open during the lifetime of the
application or to open and close it per request; I know that if I open 1
connection, but don't actually run any batches on it other connections will
use connection pooling.

Thanks
Adrian
 
S

srinivas moorthy

I dont think opening a connection thorought out the entire
life of an application is durable,scable and infact, not
suggestable. Open a connection when ever required.

thanks
srinivas moorthy
 
S

srinivas moorthy

Hi Adrian
I just want to explain you some more thing about the .Net
architecture. If u observe, the ADO is a fully connected
architecture. As long as you do the modifications to the
Data it needed to be updated to the BackEnd at the same
instance. As far as the .Net is concerned the ADO.NET
provides us the Disconnected Architecture (by native)
through the DataSet Object provided by the DataProvider in
ADO.NET.

Hope you got the basic idea of ADO.NET. I believe you knew
this but it is my answer to your question which suits best.

any queries, Welcome! :)

thanks
srinivas moorthy
 
W

William \(Bill\) Vaughn

It's okay to leave the connection open--even with ADO.NET's "disconnected"
architecture. It turns out that some applications require full-time
connectivity to manage server state and this can be done (and is being done)
using ADO.NET. Sure, if you expect to have 10,000 Windows forms applications
connecting at once, this can be an issue. However, if you're only hosting a
few to several hundred WinForms apps, then leaving the connection open
simply ties up resources on the server (which is what you might be intending
to do in the first place). These resources can be #Temp tables, server-side
cursors or other state managed by your application.
That said, it's not expensive (anymore) to close and reopen a connection and
use a JIT connection strategy. The Connection is cached for you by the
connection pool and won't timeout for several minutes after you close it.

hth

--
____________________________________
Bill Vaughn
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.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top