ADO.NET Connection object into session variable

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
 
M

Muhammad Naveed Yaseen

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.
 
M

Muhammad Naveed Yaseen

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.
 
M

Mark Rae

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...
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

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.
 
W

Walter Wang [MSFT]

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.
 
C

Charles Zhang

Thank you very much. The default behavior built into ADO.NET Provider
will be fine for me.

Charles Zhang
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top