ADO.NET Connection object into session variable

  • Thread starter Thread starter Charles Zhang
  • Start date Start date
C

Charles Zhang

I want to reuse ADO.NET Connection object from session to session, are
there any way to do that?

Thanks

Charles Zhang
 
Unless explicitly disabled, .NET itself maintains pool(s) of
connections behind the scene. Doing same thing (again) manually, may
not yield much improvement.

In case you have to implement some specific logic, you may store in
Cache or Application objects.
 
SQL Server provider of .NET framework itself maintains pool(s) of
connections behind the scene (unless explicitly disabled). Doing same
thing (again) manually, may not yield much improvement.

For other providers or to implement some specific logic, you may store
in Cache or Application objects.
 
I want to reuse ADO.NET Connection object from session to session, are
there any way to do that?

This is, possibly, one of the worst things you could do in terms of
performance in an ASP.NET app...

Create a DAL: http://aspnet.4guysfromrolla.com/articles/070203-1.aspx

so that you fetch connection objects out of the pool only when you need
them, and destroy them as soon as you're finished with them, thereby
returning them to the connection pool...
 
Do NOT do that. You'll kill your scalability.
..NET has some fairly fancy built in database connection pooling that will
efficiently manage connections for you as long as you follow this simple
rule:
Open database connections only just before you need them, and close them as
soon as you are through with them.
 
Hi Charles,

ADO.NET already supports connection pooling and it's enabled by default.
Please refer to following articles for further information:

#Understanding Connection Pooling
http://msdn2.microsoft.com/en-us/library/ms254502(VS.80).aspx

#Using Connection Pooling
http://msdn2.microsoft.com/en-us/library/8xx3tyca.aspx

#The .NET Connection Pool Lifeguard
http://msdn2.microsoft.com/en-us/library/aa175863(SQL.80).aspx

#Best Practices for Using ADO.NET
http://msdn2.microsoft.com/en-us/library/ms971481.aspx


If this default behavior doesn't work for you, would you please let us know
your requirement in detail? Thanks.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thank you very much. The default behavior built into ADO.NET Provider
will be fine for me.

Charles Zhang
 
Back
Top