473,699 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To connect to a database.

jc
Hi there:

Reading from internet i found that the best way to use a database is
to connect and disconnect on every single database request, so if you
are loading a listbox manually from a database and on the same page,
loading a grid from the database, then the best way is to connect to
database, load the listbox, disconnect, connect again, load the grid
and disconnect.

what is the cause because to reconnect many times is more
efficient?.

I tried running some test on about it,connecting once on page request
is almost 20% more fast that connecting many times.

Also, i checked the number of session open on oracle and in both
method did keep the same number of session. In any case, aspnet will
keep many connections opens (persistent?). May be this method of open
and close for request is efficient with sqlserver but other database.

Jan 11 '08 #1
3 1418
20 % from what ? Even 100 % wouldn't mean anything. If it's small enough
this is anyway non visible to the end user...

This is not really "more efficient". It just much simpler and it guarantees
that connection are released as soon as possible...

If you keep the connection opn :
- any failure to close the connection could cause problem
- it could be closed later than needed making this connection not available
even though not used
- if you have some processing between those openings, this particular
connection is not available even though not used at this time...

As most often this is a matter of trade off... The thing to check is if
your DB supports connection pooling...

--
Patrice

"jc" <jc*********@ya hoo.esa écrit dans le message de news:
b5************* *************** **...legroups .com...
Hi there:

Reading from internet i found that the best way to use a database is
to connect and disconnect on every single database request, so if you
are loading a listbox manually from a database and on the same page,
loading a grid from the database, then the best way is to connect to
database, load the listbox, disconnect, connect again, load the grid
and disconnect.

what is the cause because to reconnect many times is more
efficient?.

I tried running some test on about it,connecting once on page request
is almost 20% more fast that connecting many times.

Also, i checked the number of session open on oracle and in both
method did keep the same number of session. In any case, aspnet will
keep many connections opens (persistent?). May be this method of open
and close for request is efficient with sqlserver but other database.

Jan 11 '08 #2
"jc" <jc*********@ya hoo.eswrote in message
news:b5******** *************** ***********@l1g 2000hsa.googleg roups.com...
Reading from internet i found that the best way to use a database is
to connect and disconnect on every single database request, so if you
are loading a listbox manually from a database and on the same page,
loading a grid from the database, then the best way is to connect to
database, load the listbox, disconnect, connect again, load the grid
and disconnect.
That's the generally accepted wisdom, yes...
what is the cause because to reconnect many times is more
efficient?.
Yes, because of a feature of ADO.NET called connection pooling. With web
applications, "little and often" is definitely the way to go...
I tried running some test on about it,connecting once on page request
is almost 20% more fast that connecting many times.
How are you creating / destroying the connections...?
In any case, ASP.NET will keep many connections opens (persistent?).
If your web app has persistent connections with your RDBMS, then you need to
rethink your connectivity method...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 11 '08 #3
"Patrice" <http://www.chez.com/scribe/wrote in message
news:u4******** ******@TK2MSFTN GP05.phx.gbl...
The thing to check is if your DB supports connection pooling...
The OP is using Oracle which definitely does support connection pooling, but
only if accessed correctly:
http://weblogs.asp.net/ngur/archive/.../21/61207.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 11 '08 #4

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

Similar topics

20
4813
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " . mysql_error()); echo "Connected successfully"; mysql_close($link);
1
4801
by: DAVID | last post by:
Hello, With regards to the Connect dialog on Oracle forms 6i via which we can connect to Oracle database, should we use the same functionality on forms run time again? I mean, I want to make a window with three screen items for username, password and service name. And on run time after connecting to the database I use this window to reconnect to an other database. So when I give the appropriate information, I will connect to the
3
6062
by: Lee | last post by:
Hi, I'm developing a socket program to connect to Informix database through the ODBC. In here i called my socket program as "tap" . My tap will listen for data from unix through port 1070. After checking of the data, tap will then insert the data to the informix database. I know we can point the tap to one specified port in Informix database through the services file. My question is how should i know to which port my tap program send out...
4
5598
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or SQLNET in ORACLE that would allow me to connect to a database on a remote box (either AIX or AS/400)? I have read that DB2 Connect appears to be the ticket for the Db2 server if it is on AS/400 or OS/390. What if it is on AIX? Does the same tool...
4
6471
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to define the servername / hostname in my Perl Progrem.. Here is the code:
3
4565
by: Jassim Rahma | last post by:
I would like to know what is the best way to onnect to connect to a database in general which provides you with full functionality & fast access? Best Regards, Jassim Rahma *** Sent via Developersdex http://www.developersdex.com ***
1
2044
by: GNoter | last post by:
Scenario: I've a WebFarm with 2 web servers which are NLBs (network load balanced). Web1 and Web2; they are not part of a domain. I have a third server, Server3, which is part of a domain and on the same physical network, and it has an MSAccess database which is used on the external webfarm as well as on the internal intranet. I can connect via the intranet because the DB file is on the same box from which the intranet is being served...
21
2328
by: Steve | last post by:
I moved my database from one server to another SQL server. I did a backup and restore of the database. I can connect to the database on server A from my asp.net app but when I try to connect to my database server B, I'm gettting 'login failed for user 'username' I've added the username to the database on server B, I can open up SMS and connect to the database that way, but I can't connect from my asp.net web app. any suggestions on what...
2
9789
by: jeffhan | last post by:
we have os/400 db2 database at the backend. i installed db2 v9 connect server on one windows server which is locating the same network with database server. now how to i configure the connect server and client, so client could access the database through the connect server? like that: db2client <--db2 connect server <--db2 mainframe database
5
3126
by: danfan46 | last post by:
Hi! I have a previous post on the subject that connect takes a long time. I uninstalled db2 completely. Installed V9.5 Installed fixpack 1 created das created an instance installed database sample.
0
8686
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
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
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
9033
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
8911
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.