472,328 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 4776
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...
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....
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.