473,783 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keep an ADO Connection open


I created a web method to insert data on a DB2 database.

It runs well, except every time I call it, it opens and closes the ADO
connection.

I think it would run faster, since I send it hundreds of records, if I
could just keep a connection open at the point the web service starts up
and close it when the web service is shut down ( so I would open it in
the Application_Sta rt and close it in the Application_End ).

Could that be done? Or should I make the ADO Connection object a
static global in the web service?

Could I make all the web service inserts run on that Connection?

Would it be thread-safe if I called the web method asynchronously?

Nov 23 '05 #1
8 4141
"ja*****@texeme .com" <ja*****@texeme .com> wrote in news:95WdnVFp9r lv1VnfRVn-
sA@speakeasy.ne t:
Could that be done? Or should I make the ADO Connection object a
Why not just use connection pooling? Surely ADO supports that.
static global in the web service?


You will have to protect access to it, and then under load you will have performance problems as
all requests will be sharing a single connectino.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 23 '05 #2
"ja*****@texeme .com" <ja*****@texeme .com> wrote in news:95WdnVFp9r lv1VnfRVn-
sA@speakeasy.ne t:
Could that be done? Or should I make the ADO Connection object a
Why not just use connection pooling? Surely ADO supports that.
static global in the web service?


You will have to protect access to it, and then under load you will have performance problems as
all requests will be sharing a single connectino.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 23 '05 #3
On Thu, 30 Jun 2005 12:33:07 -0700, "ja*****@texeme .com" <ja*****@texeme .com> wrote:

¤
¤ I created a web method to insert data on a DB2 database.
¤
¤ It runs well, except every time I call it, it opens and closes the ADO
¤ connection.
¤
¤ I think it would run faster, since I send it hundreds of records, if I
¤ could just keep a connection open at the point the web service starts up
¤ and close it when the web service is shut down ( so I would open it in
¤ the Application_Sta rt and close it in the Application_End ).
¤
¤ Could that be done? Or should I make the ADO Connection object a
¤ static global in the web service?
¤
¤ Could I make all the web service inserts run on that Connection?
¤
¤ Would it be thread-safe if I called the web method asynchronously?

This is too much trouble and I wouldn't bother. Connection pooling is enabled by default so if your
DB2 provider or driver supports connection pooling it would probably be a waste of database
resources to maintain persistent connections.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 23 '05 #4
On Thu, 30 Jun 2005 12:33:07 -0700, "ja*****@texeme .com" <ja*****@texeme .com> wrote:

¤
¤ I created a web method to insert data on a DB2 database.
¤
¤ It runs well, except every time I call it, it opens and closes the ADO
¤ connection.
¤
¤ I think it would run faster, since I send it hundreds of records, if I
¤ could just keep a connection open at the point the web service starts up
¤ and close it when the web service is shut down ( so I would open it in
¤ the Application_Sta rt and close it in the Application_End ).
¤
¤ Could that be done? Or should I make the ADO Connection object a
¤ static global in the web service?
¤
¤ Could I make all the web service inserts run on that Connection?
¤
¤ Would it be thread-safe if I called the web method asynchronously?

This is too much trouble and I wouldn't bother. Connection pooling is enabled by default so if your
DB2 provider or driver supports connection pooling it would probably be a waste of database
resources to maintain persistent connections.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 23 '05 #5
Paul Clement wrote:

ould it be thread-safe if I called the web method asynchronously?

This is too much trouble and I wouldn't bother. Connection pooling is
enabled by default so if your DB2 provider or driver supports connection
pooling it would probably be a waste of database resources to maintain
persistent connections.


Research shows that it supports it by default -- so, agreed, it's not
necessary.

--
Texeme Textcasting Technology
http://www.texeme.com
Nov 23 '05 #6
Paul Clement wrote:

ould it be thread-safe if I called the web method asynchronously?

This is too much trouble and I wouldn't bother. Connection pooling is
enabled by default so if your DB2 provider or driver supports connection
pooling it would probably be a waste of database resources to maintain
persistent connections.


Research shows that it supports it by default -- so, agreed, it's not
necessary.

--
Texeme Textcasting Technology
http://www.texeme.com
Nov 23 '05 #7
Chad Z. Hower aka Kudzu wrote:
Why not just use connection pooling? Surely ADO supports that.


Yes, you're correct, it looks like it's enabled by default.

--
Texeme Textcasting Technology
http://www.texeme.com
Nov 23 '05 #8
Chad Z. Hower aka Kudzu wrote:
Why not just use connection pooling? Surely ADO supports that.


Yes, you're correct, it looks like it's enabled by default.

--
Texeme Textcasting Technology
http://www.texeme.com
Nov 23 '05 #9

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

Similar topics

1
2818
by: Robin Tucker | last post by:
Just a quick question about connection management. My application will never need more than 1 or 2 connections about at any given time. Also, I do not expect many users to be connected at any given time. For efficiency, I would like to keep connections alive throughout the lifetime of the objects requiring them, rather than opening a new connection, executing code and then closing it again. What is the most efficient way of doing this?...
1
4093
by: Jim Mitchell | last post by:
I store my connect string in the viewstate and open and close the SQL database in every function or sub-routine call. Is there a better method of opening the database when the ASPX page opens and cleanly closing it when the page exits? I guess the on open part is easy, but how do I know that the page closes so that I can be sure to close out the database connection? What happens if I do a server.transfer from any of the pages? Do I...
4
389
by: jabailo | last post by:
I created a web method to insert data on a DB2 database. It runs well, except every time I call it, it opens and closes the ADO connection. I think it would run faster, since I send it hundreds of records, if I could just keep a connection open at the point the web service starts up and close it when the web service is shut down ( so I would open it in the Application_Start and close it in the Application_End ).
13
1902
by: Larry | last post by:
Hi I have asp.net programs. I used a very simple data transfer method by using URLs ¡°First.aspx¡± contents a line to send data to the ¡°second.aspx¡± page, for
11
2436
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a database through Connection.open() method, and I do not use Connection.close() method, will garbage collector collect the connection object just because i am not using it any more. 2) I am using a dataset, in which i make some modifications to the...
3
6351
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want to keep those variables, as an alternative, as ViewState variables because I don't want to transfer to many hidden fields. This is the code I use :
16
2875
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with a worker thread that would execute the db commands. The pool was fixed and all the connections were created when the db access class was instantiated. The connections remained opened during the whole execution. If a connection was not available...
20
3299
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how many connection has been used ? 2. If the maximum pool size has been reached, what happens when I call the method Open to open the connection ? Will I get an error ? MSDN says the request is queued, but will I get an error in the open method ? ...
6
4030
by: TheSteph | last post by:
Hi, (using C#, VS2005, .NET 2.0.) I sometimes need to access my database (SQL Server) in SINGLE_USER mode.
5
5010
by: vieraci | last post by:
Hi, I'm wanting to start a database connection at the start of an app and keep it open for all methods and classes that I'm #including in my project. First I went about it by creating the connection in the Main source file outside of any class declarations and then declaring it external in other source files. // Main cpp file #include <mysql++> mysql::Connection * conn;
0
9946
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
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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
6737
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
5379
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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.