Keep an ADO Connection open

  • Thread starter Thread starter jabailo
  • Start date Start date
J

jabailo

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?
 
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/
 
¤
¤ 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)
 
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.
 
Back
Top