473,788 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use one database connection object per page request

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 a database object to query data from
database (using MySQL database). So it means that for each page request I am
using 7 or 8 database connection which is something quite bad as far as
performance is concerned. So please tell me how can change my design to use
only one database connection object per page request? Important thing is I
need to close database connection also once page request is fulfil and if I
dont close database connection then database connection is still there for a
very long time and it could cause bottleneck at my database server for more
new connections.

Thanks,

Arsalan

May 20 '06 #1
6 3443
as each control is loaded, it will open, run, then close the connection. There should be no problem so long as each has the
open/close statements in the code.


"Arsalan Ahmad" <ar*****@hotmai l.com> wrote in message news:eC******** ******@TK2MSFTN GP03.phx.gbl...
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 a database object to query data from database (using MySQL database).
So it means that for each page request I am using 7 or 8 database connection which is something quite bad as far as performance is
concerned. So please tell me how can change my design to use only one database connection object per page request? Important thing
is I need to close database connection also once page request is fulfil and if I dont close database connection then database
connection is still there for a very long time and it could cause bottleneck at my database server for more new connections.

Thanks,

Arsalan

May 20 '06 #2
This good be total off but http://www.asp.net/guidedtour2/s11.aspx

I am new, but i happen to come across the link.

May 20 '06 #3
Arsalan Ahmad wrote:
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 a database object to query data from
database (using MySQL database). So it means that for each page request I am
using 7 or 8 database connection which is something quite bad as far as
performance is concerned. So please tell me how can change my design to use
only one database connection object per page request? Important thing is I
need to close database connection also once page request is fulfil and if I
dont close database connection then database connection is still there for a
very long time and it could cause bottleneck at my database server for more
new connections.

Thanks,

Arsalan


Which data provider are you using? The OleDbConnection and
OdbcConnection classes both support connection pooling, so if you're
using either of them, it shouldn't be an issue to follow the "open a
connection, do a command, close the connection" model. It looks like
you'll use a lot of connections, but behind the scenes the connection
pool will manage it for you.

Damien

May 21 '06 #4
Hi,

I am using MySQL .NET Connector and I am afraid that it does not support
connection pooling and that is why I think that opening a new connection by
each control in a page request will make it quite slow.

Regards,

Arsalan

"Damien" <Da************ *******@hotmail .com> wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com...
Arsalan Ahmad wrote:
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 a database object to query data from
database (using MySQL database). So it means that for each page request I
am
using 7 or 8 database connection which is something quite bad as far as
performance is concerned. So please tell me how can change my design to
use
only one database connection object per page request? Important thing is
I
need to close database connection also once page request is fulfil and if
I
dont close database connection then database connection is still there
for a
very long time and it could cause bottleneck at my database server for
more
new connections.

Thanks,

Arsalan


Which data provider are you using? The OleDbConnection and
OdbcConnection classes both support connection pooling, so if you're
using either of them, it shouldn't be an issue to follow the "open a
connection, do a command, close the connection" model. It looks like
you'll use a lot of connections, but behind the scenes the connection
pool will manage it for you.

Damien

May 21 '06 #5
On Sun, 21 May 2006 20:22:23 +0200, "Arsalan Ahmad"
<ar*****@hotmai l.com> wrote:
Hi,

I am using MySQL .NET Connector and I am afraid that it does not support
connection pooling and that is why I think that opening a new connection by
each control in a page request will make it quite slow.

Regards,

Arsalan

"Damien" <Da************ *******@hotmail .com> wrote in message
news:11******* *************** @38g2000cwa.goo glegroups.com.. .
Arsalan Ahmad wrote:
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 a database object to query data from
database (using MySQL database). So it means that for each page request I
am
using 7 or 8 database connection which is something quite bad as far as
performance is concerned. So please tell me how can change my design to
use
only one database connection object per page request? Important thing is
I
need to close database connection also once page request is fulfil and if
I
dont close database connection then database connection is still there
for a
very long time and it could cause bottleneck at my database server for
more
new connections.

Thanks,

Arsalan


Which data provider are you using? The OleDbConnection and
OdbcConnection classes both support connection pooling, so if you're
using either of them, it shouldn't be an issue to follow the "open a
connection, do a command, close the connection" model. It looks like
you'll use a lot of connections, but behind the scenes the connection
pool will manage it for you.

Damien


My understanding is that if you put connectionpooli ng in your connect
string to mysql, independent of the driver in .net, you will get
connection pooling to the database. Let me know if this is wrong, but
I don't think so.
Peter Kellner
http://peterkellner.net
May 21 '06 #6
Arsalan Ahmad wrote:
Hi,

I am using MySQL .NET Connector and I am afraid that it does not support
connection pooling and that is why I think that opening a new connection by
each control in a page request will make it quite slow.

Regards,

Arsalan
In that case, I would suggest (if you want to do one connection per
request), to create a base page which in an early event (say in the
Init event), opens a connection and puts it into
HttpContext.Cur rent.Items, and which closes it in the Unload event.
Then everything that needs a connection in between will retrieve it
from the Items connection.

However, I wouldn't expect this to scale well. You may be better suited
to roll your own connection pool (assuming that your connection string
is always the same, this may not be too onerous), assuming that your
individual operations are independent.

Damien
"Damien" <Da************ *******@hotmail .com> wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com...
Arsalan Ahmad wrote:
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 a database object to query data from
database (using MySQL database). So it means that for each page request I
am
using 7 or 8 database connection which is something quite bad as far as
performance is concerned. So please tell me how can change my design to
use
only one database connection object per page request? Important thing is
I
need to close database connection also once page request is fulfil and if
I
dont close database connection then database connection is still there
for a
very long time and it could cause bottleneck at my database server for
more
new connections.

Thanks,

Arsalan


Which data provider are you using? The OleDbConnection and
OdbcConnection classes both support connection pooling, so if you're
using either of them, it shouldn't be an issue to follow the "open a
connection, do a command, close the connection" model. It looks like
you'll use a lot of connections, but behind the scenes the connection
pool will manage it for you.

Damien


May 22 '06 #7

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

Similar topics

1
4169
by: Ben M. | last post by:
Greetings all, This should be an easy task, and Im sure it is, but as many times as I have tried, I cant seem to get this to work properly. We changed ISPs recently from a shared host to a co-located server, and our former host was nice enough to send us a backup of our old SQL2000 database (about 5MB). I went into Enterprise Manager, created an empty database with the same name
4
3862
by: Jim in Arizona | last post by:
I'm wanting to do a simple controlled voting page. I too our webserver off anonymous and everyone who accesses the website is a domain authenticated user. I've already done some control structure pages based on Request.ServerVariables("AUTH_USER"), which works great. That's also how I would do this page, in my basic thinking. My idea is to have an access database with two tables. One table will have the vote written to it and the other...
3
2614
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session object is lost after I've made a call to the database. To test, I've created two test aspx pages. Test1.aspx contains two buttons. The first button sets values in the session object and then navigates to Test2.aspx. Test2.aspx only displays the values in the session object. The second button...
1
2023
by: Rico | last post by:
I have tried to access a database using asp.net. after some entries like 120+, I got an unspecified error message. Anyone know what is happening, it seems to be stuck at the same line even when i added a new line. Here is the error message: Server Error in '/sonamy' Application. -------------------------------------------------------------------------------- Unspecified error
35
4851
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 string in the web.config. I created a class with a static database connection and the class opens and closes the database.
2
2531
daJunkCollector
by: daJunkCollector | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The form uploads to a database (the following code does this) 2. An e-mail notification is sent to a specified e-mail address. (I know this can be done in the database, but I would prefer it be contained within the ASP code for now, but cannot find...
1
7552
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is quick and adaptive. I generally use a frames page for the search, in this way the search is maintained...
4
3034
by: coldpizza | last post by:
Hi, I want to run a database query and then display the first 10 records on a web page. Then I want to be able to click the 'Next' link on the page to show the next 10 records, and so on. My question is how to implement paging, i.e. the 'Next/Prev' NN records without reestablishing a database connection every time I click Next/Prev? Is it at all possible with cgi/mod_python?
3
1848
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 is in second one. The first application is used for order management. I have defined in Main.aspx page a variable called localSqlConnection. Every time i enter this page (only one time per session) i create connection to local database and then i...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10364
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.