473,396 Members | 2,024 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,396 software developers and data experts.

Database connection pooling in ASPx

In the Windows application (using VB.NET 2005) I use connection pooling like
the following:
In the main form load I open a connection using a connection string that I
stored in a global variable g_sConnectionString and leave this connection
open and not close it until it exits the application.
Then on each thread/each subsequent sub that needs the connection I create a
local OleDBConnection variable, open the connection using the exact same
connection string as the main form (stored
in global variable g_sConnectionString), and close it after populating a
DataSet.
Then, in the FormClosing event of the main form I close the database
connection.

In an ASPX application the user can close the browser at any page. Do I do
the connection pooling the same way in ASPX where I open the connection at
the Startup Page, leave that connection open, and at subsequent pages I open
connection (using the exact same connection string as the Startup Page) and
close the connection, then at the Startup Page Unload event close the 1st
connection ?
Since user can close the browser at any page, where is the best place to
close the 1st database connection (the one opened in the Startup Page) ?

Thank you.
Apr 23 '07 #1
3 4870
Connection pooling is done for you. Just open/close connections when needed.
They are not actually closed but just returned to the pool ready to be
returned from the pool when you "open" another connection.

This way you can server a given number of users which much less connexion
than users.

Note that I'm not sure what is the purpose of the global connexion as my
understanding is that you are opening anyway a local connection when needed.
If this is just to keep around the connection string you could keep just the
connection string rather than an opened global connection.

So in short you don't need to open a global connexion in ASP.NET (or
Windows) to benefit from connection pooling. Just open/close a connexion
when needed and the provider should take care of pooling for you (or what is
the DB you are using ?)

---
Patrice
"fniles" <fn****@pfmail.coma écrit dans le message de news:
u7**************@TK2MSFTNGP04.phx.gbl...
In the Windows application (using VB.NET 2005) I use connection pooling
like the following:
In the main form load I open a connection using a connection string that I
stored in a global variable g_sConnectionString and leave this connection
open and not close it until it exits the application.
Then on each thread/each subsequent sub that needs the connection I create
a local OleDBConnection variable, open the connection using the exact same
connection string as the main form (stored
in global variable g_sConnectionString), and close it after populating a
DataSet.
Then, in the FormClosing event of the main form I close the database
connection.

In an ASPX application the user can close the browser at any page. Do I do
the connection pooling the same way in ASPX where I open the connection at
the Startup Page, leave that connection open, and at subsequent pages I
open connection (using the exact same connection string as the Startup
Page) and close the connection, then at the Startup Page Unload event
close the 1st connection ?
Since user can close the browser at any page, where is the best place to
close the 1st database connection (the one opened in the Startup Page) ?

Thank you.

Apr 23 '07 #2
Thank you.
Sorry for the misunderstanding: I do not use a global connection, I use a
global connection string variable, so that on every form/page I can open
connection using that connection string.
One of our application uses SQL Server 2000, another SQL Server 2005,
another MS Access.

I thought that in the main form/startup page I need to open a database
connection (using a local connection variable), leave that open, then in
other subsequent forms when I open the db connection (also using a local
connection variable) it uses the connection pooling in the 1st form/page ?
Then I close the connection in this subsequent forms. I thought that if on
every page/form (including the 1st page/startup form) I open and close the
connection I won't be using connection pooling ? Do I understand it wrong ?
Are you saying that I can open/close connections on every form/page
(including the 1st page/startup form) as long as I open the connection using
the exact same connectiong string, and it knows to use connection pooling
everytime I open/close the connection?

Thanks again.

"Patrice" <http://www.chez.com/scribe/wrote in message
news:Od**************@TK2MSFTNGP03.phx.gbl...
Connection pooling is done for you. Just open/close connections when
needed. They are not actually closed but just returned to the pool ready
to be returned from the pool when you "open" another connection.

This way you can server a given number of users which much less connexion
than users.

Note that I'm not sure what is the purpose of the global connexion as my
understanding is that you are opening anyway a local connection when
needed. If this is just to keep around the connection string you could
keep just the connection string rather than an opened global connection.

So in short you don't need to open a global connexion in ASP.NET (or
Windows) to benefit from connection pooling. Just open/close a connexion
when needed and the provider should take care of pooling for you (or what
is the DB you are using ?)

---
Patrice
"fniles" <fn****@pfmail.coma écrit dans le message de news:
u7**************@TK2MSFTNGP04.phx.gbl...
>In the Windows application (using VB.NET 2005) I use connection pooling
like the following:
In the main form load I open a connection using a connection string that
I stored in a global variable g_sConnectionString and leave this
connection open and not close it until it exits the application.
Then on each thread/each subsequent sub that needs the connection I
create a local OleDBConnection variable, open the connection using the
exact same connection string as the main form (stored
in global variable g_sConnectionString), and close it after populating a
DataSet.
Then, in the FormClosing event of the main form I close the database
connection.

In an ASPX application the user can close the browser at any page. Do I
do the connection pooling the same way in ASPX where I open the
connection at the Startup Page, leave that connection open, and at
subsequent pages I open connection (using the exact same connection
string as the Startup Page) and close the connection, then at the Startup
Page Unload event close the 1st connection ?
Since user can close the browser at any page, where is the best place to
close the 1st database connection (the one opened in the Startup Page) ?

Thank you.


Apr 23 '07 #3
On Mon, 23 Apr 2007 12:59:26 -0500, "fniles" <fn****@pfmail.comwrote:

¤ I thought that in the main form/startup page I need to open a database
¤ connection (using a local connection variable), leave that open, then in
¤ other subsequent forms when I open the db connection (also using a local
¤ connection variable) it uses the connection pooling in the 1st form/page ?
¤ Then I close the connection in this subsequent forms. I thought that if on
¤ every page/form (including the 1st page/startup form) I open and close the
¤ connection I won't be using connection pooling ? Do I understand it wrong ?
¤ Are you saying that I can open/close connections on every form/page
¤ (including the 1st page/startup form) as long as I open the connection using
¤ the exact same connectiong string, and it knows to use connection pooling
¤ everytime I open/close the connection?
¤

Yes. As was mentioned it's enabled by default. Connection pools are created per process or app pool
and per connection string.
Paul
~~~~
Microsoft MVP (Visual Basic)
Apr 24 '07 #4

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

Similar topics

14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
4
by: Mike | last post by:
Assume i have a db connection and a datareader for that connection. Now I perform a query that retrieves 100MB of data. I know that the data reader gets 1 row at a time. However, there is a...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
3
by: Hahn, Thomas | last post by:
Hallo, I have an ASP.NET application with masterpages, skins and diffrent themes. The application works fine, but the performance is not realy good. If I load an ASPX file, which has no database...
4
by: Michael C | last post by:
Hi All, I'm trying to drop an sqlserver database from c# but can't because it is claiming it is in use. As I don't have a connection to it it must be connection pooling that is causing the...
8
by: BD | last post by:
I am developing C# win form app to work with remote database on SQL Server 2005. Problem scenario is as follows: 1. a form is open that has downloaded dataset to local cache 2. computer is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.