473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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_Start 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 4095
"ja*****@texeme.com" <ja*****@texeme.com> wrote in news:95WdnVFp9rlv1VnfRVn-
sA@speakeasy.net:
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/
"Programming 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:95WdnVFp9rlv1VnfRVn-
sA@speakeasy.net:
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/
"Programming 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_Start 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_Start 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
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...
1
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...
4
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...
13
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
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...
3
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...
16
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...
20
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...
6
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
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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
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
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,...

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.