473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ADO.NET Connection object into session variable

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

Thanks

Charles Zhang
Mar 9 '07 #1
6 2981

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.

Mar 9 '07 #2
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.

Mar 9 '07 #3
"Charles Zhang" <Ch**********@newsgroups.nospamwrote in message
news:ec**************@TK2MSFTNGP02.phx.gbl...
>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...
Mar 9 '07 #4
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.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Charles Zhang" <Ch**********@newsgroups.nospamwrote in message
news:ec**************@TK2MSFTNGP02.phx.gbl...
>I want to reuse ADO.NET Connection object from session to session, are
there any way to do that?

Thanks

Charles Zhang
Mar 9 '07 #5
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/lib...02(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/lib...3(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 (wa****@online.microsoft.com, 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.

Mar 12 '07 #6
Thank you very much. The default behavior built into ADO.NET Provider
will be fine for me.

Charles Zhang
Walter Wang [MSFT] wrote:
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/lib...02(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/lib...3(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 (wa****@online.microsoft.com, 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.
Mar 14 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bina Desai | last post by:
I get the following error: Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: '' /myweb4/authorised_user_page.asp, line 70 and line 70 of my code is: <% rsCheckUser1.Open...
3
by: Grigs | last post by:
Hello, I have a web service that reads its web.config file to connect to an Oracle database. There are a number of methods in this socalled BACKBONE that either send inforomation to or from the...
18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
15
by: Rob Nicholson | last post by:
I'm starting to worry a bit now. We're getting the above error when two users hit the same database/page on an ASP.NET application using ADO.NET, talking to a SQL 7 server. The error is perfectly...
1
by: booksnore | last post by:
I have an application where a have a single admin database and multiple customer databases containing the customer's warehouse data. In the admin database I hold a user table and also a client...
37
by: sam44 | last post by:
Hi, At startup the user log on and chooses the name of a client from a dropdownlist, which then changes dynamically the connection string (the name of the client indicates which database to use)....
6
by: Mike | last post by:
We are intermitantly receiving this error on our website. ExecuteReader requires an open and available Connection. The connection's current state is connecting. Following is the code from the Load...
3
eboschi
by: eboschi | last post by:
Hi all, i'm new to .net programming and i have some problems with database connection. I have written two web application. Both of them use ADODB Connection to Sql Server 2000 database. The problem...
11
by: User Groups | last post by:
I want to have an asp page that can connect to a TCP listener and send some data to it. I have done some coding and was able to send data to the listener but for one time only. As soon as a...
8
by: vinod allapu | last post by:
Hi all, I have some webpages in my project, each web page contains same connection object more than one time . I want to store a single connection object in a session variable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.