Re: SqlConnection Object in Application Variable OR Session Variable OR open/close

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



1. This is the most horrible method. All users would share the same
connection object, which means, you are going to have multiple threads
trying to use it at once, which means your app will crash instance under any
kind of load.

2. This is slightly better, but still really bad. First off, it means you
have an open connection the entire lifetime of a session. This severely
limits the number of concurrent users, and performs badly.

3. This is how you should handle it. Connections are pooled by default,
opening and closing them is relatively inexpensive. Additionally, you will
get much better performance by not keeping unecessary connections open, 99%
of which time they are not being used.

So yes, #3 is the way to go.

"pratham" <praveen.config@xxxxxxxxx> wrote in message
news:1157042602.098674.82410@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi and regards

What is best method to have an connection to sql, iam using sqlserver

1. have an sqlconnection open when the application start event in
global.asax so that i dont have to open it in each method where i
require to open an connection

2. open an connection in seesion so that, it is available in session of
the user thorugh out

3. open an connection in each method and close after the requried
operation is completed

which is better

as per the 3rd method ... doest openning and closing in each method is
a bad??

Comments expected



.



Relevant Pages

  • Re: APPN Connection z/os - AHHC / LLC2.
    ... implied that you session stopped for a while and then continued. ... the ANNC link is a type 2.1 connection. ... I would suggest trying to limit the request unit size used over the type 2.1 ... MAXDATA operand when defining a PU statement for an adjacent link station ...
    (bit.listserv.ibm-main)
  • Re: Remote desktop deadlock on XP SP2
    ... the TS connection is frozen, even if I specify a wait timeout. ... TermSrv.dll creates a new session for the purpose of displaying the logon ... lives on a DPC routine for the network miniport ... the network packets are encapsulated and decapsulated in UDP. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: JES-APPL
    ... Then there has been a session initiation request - which can only happen over an available session path - this isn't any of your flaky IP, ... Unless the NJE application on the AS/400 has consistently been caught in the middle of being activated in some way - highly unlikely I would expect - this is not a timing problem. ... Since the connection is necessarily in place, there is no problem with the connection - just in case a modem is involved - which, given a "switched" definition is used, is not impossible, but unlikely. ...
    (bit.listserv.ibm-main)
  • Re: os users, sessions, and connections.
    ... From what I've read a session is a logged connection. ... do the following (paddr is the address of the process ... select sid, serial#, paddr, username from v$session ...
    (comp.databases.oracle.server)
  • Re: Some outstanding ASP .NET questions
    ... Typically, we store the connection in the ... Session and use a Singleton pattern to retrieve it back later: ... Is it appropriate to store table key information in the session? ... I was referring to primary keys in database tables. ...
    (microsoft.public.dotnet.languages.csharp)