473,486 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what is the best way to manage about 2000 database connection / mssql+ asp.net

Hi there
Anybody knows what is the best way to manage creation 2000 of the
database connections at the same time?

Now Im doing it somethink like this:

using ( Connection conn = Connection.Create )
{
conn.Open();
//...
}

....but I thinks that isn't a good solution because every (of 2000)
visitor who enters to the site always gets a new connection. Every
refresing page creates a new connection.

In my opinion this solve isn't good. So, what is the best way to do it
right? Am I always must create a new connection for every page
refresing? Could I cache it...? or .. what?
Dec 1 '07 #1
4 1313
"la*****@gmail.com" <la*****@gmail.comwrote in news:5de6a991-4fdb-42cf-
b8***************@e6g2000prf.googlegroups.com:
In my opinion this solve isn't good. So, what is the best way to do it
right? Am I always must create a new connection for every page
refresing? Could I cache it...? or .. what?

You should open the connection as late as possible, and close the
connection as early as possible.

..NET has internal connection pooling, so there is no need for you to manage
the connection pool unless you're doing something out of the ordinary.
Dec 1 '07 #2
The SqlConnection class (System.Data.SqlClient.SqlConnection) provides
automatic connection pooling. The other "built-in" connections may as well.
Check the help files for details then post again if you have specific
questions.

If you are using some sort of custom data connection, then you may need to
implement your own connection pooling. I imagine a quick Google search on
"asp.net connection pooling" will turn up plenty of results.

Here's a start:
http://aspalliance.com/1099_Understa...oling_in_NET.1

Scott

<la*****@gmail.comwrote in message
news:5d**********************************@e6g2000p rf.googlegroups.com...
Hi there
Anybody knows what is the best way to manage creation 2000 of the
database connections at the same time?

Now Im doing it somethink like this:

using ( Connection conn = Connection.Create )
{
conn.Open();
//...
}

...but I thinks that isn't a good solution because every (of 2000)
visitor who enters to the site always gets a new connection. Every
refresing page creates a new connection.

In my opinion this solve isn't good. So, what is the best way to do it
right? Am I always must create a new connection for every page
refresing? Could I cache it...? or .. what?
Dec 1 '07 #3
Make sure your connection string uses pooling. This way you would pool from
a collection of connections so when you call a connection.Open() method, it
first sees if there's a connection in the pool and then will use an
available connection. A lot of this is already handled for you behind the
scenes by ADO.Net so you don't have to worry about it so much. The general
rule though, only have your connection open for the length of time you need
it then close it right away. This frees it up to be used by some other page.

Instead of caching the connections, you should be looking at where you can
use the built-in output caching for a web page or control. If you are
creating news for a site, then make sure the page caches itself so that
you're only calling for a fresh set of data every 20 minutes or so, no need
to cache the connection here, just the resultant page since it's not
changing that often.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
<la*****@gmail.comwrote in message
news:5d**********************************@e6g2000p rf.googlegroups.com...
Hi there
Anybody knows what is the best way to manage creation 2000 of the
database connections at the same time?

Now Im doing it somethink like this:

using ( Connection conn = Connection.Create )
{
conn.Open();
//...
}

...but I thinks that isn't a good solution because every (of 2000)
visitor who enters to the site always gets a new connection. Every
refresing page creates a new connection.

In my opinion this solve isn't good. So, what is the best way to do it
right? Am I always must create a new connection for every page
refresing? Could I cache it...? or .. what?
Dec 1 '07 #4
On 1 Gru, 21:26, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Make sure your connection string uses pooling.
ofcorse, it uses
This way you would pool from
a collection of connections so when you call a connection.Open() method, it
first sees if there's a connection in the pool and then will use an
available connection. A lot of this is already handled for you behind the
scenes by ADO.Net so you don't have to worry about it so much. The general
rule though, only have your connection open for the length of time you need
it then close it right away. This frees it up to be used by some other page.
ok
Instead of caching the connections, you should be looking at where you can
use the built-in output caching for a web page or control. If you are
creating news for a site, then make sure the page caches itself so that
you're only calling for a fresh set of data every 20 minutes or so, no need
to cache the connection here, just the resultant page since it's not
changing that often.
ok, so Im using it in the right way.
I use caching output, pooling, I open the connection only for the time
when I need. Great.

Thaks all of You for the answers.
>
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
Dec 1 '07 #5

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

Similar topics

1
3369
by: Macca | last post by:
Hi, I have a C# Solution/Application that contain 4 projects. Each of these projects needs at some time to access the same database. I would like to know how to share a single connection...
3
1973
by: OL | last post by:
Hello All, I need help understanding DB connection mgmt. Scenario: - 3 separate Web application - IIS 5 or 6 - dynamic pages for most part - DB Backend is Adaptive server Anywhere from...
8
1213
by: Nick N. | last post by:
Hi all, I just started to play around with VB.Net. I currenlty do Powerbuilder work and was wondering how database connection management works in VB.net. My applications typically pop-up a...
3
10270
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...
6
3428
by: Arsalan Ahmad | last post by:
Hi all, I am creating a website in which in an Item detail page there are a number of web controls (7 or 8) and what is happening that inside each of control's Page_Load() function I am creating...
0
1548
by: Hongbo | last post by:
Hi, I have a test server with Windows 2003 Standard Server. SQL Server 2000 Standard Edition was installed earlier as default instance. My ASP.Net web site works fine with the connection...
3
4875
by: fniles | last post by:
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...
3
2597
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
Last week I asked a question about connection to database from client machine (developer machine). I have changed the database security setup for "SQL Server and Windows" under (local)Windows NT...
1
1105
by: anujaf | last post by:
Hi! What are the available Database connection methods (ex. ODBC, OLEDB ..) How to choose the best connection method. and the differences of all these mothods. For the SQL server web...
0
7123
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,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
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
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.