Open/Close Connection String

Open/Close Connection String

Post by Yagtin » Tue, 09 Oct 2001 10:38:42



Is it a good practice to open and close an ADO connection for each
select/Insert/Update statements? Or I should reuse the connection for every
select/Insert/Update statements?
 
 
 

Open/Close Connection String

Post by Bill » Tue, 09 Oct 2001 16:23:13


Theres the start of an argument.  Check above in the post "About ADO
connection?"  29/09/2001.  You'll get people arguing both methods (1
connection vs. open them as you need them).  I think it depends on your
particular situation.  What you connection limits are for the database, how
many users, etc... but that's just my opinion.  Most apparently believe in
opening/closing as you need them.  But in my view that is way too slow if
you can keep one connection open for each active user and use it for all
your recordsets, why not (it's much faster)?  Anyhow check above for some
opinions that are most likely better informed than mine.  Hope that helps
Bill


Quote:> Is it a good practice to open and close an ADO connection for each
> select/Insert/Update statements? Or I should reuse the connection for
every
> select/Insert/Update statements?


 
 
 

Open/Close Connection String

Post by Yagtin » Tue, 09 Oct 2001 14:34:21


Thanks a lot Bill Got an idea.. by the way, the connection string I used is
declared as a Public variable in my Activex DLL's start up module.
Previously the set up for this connection was that of a Close/Open
situation. I noticed that the web server where the activex where hosted
always hangsup. I suspect it to the connection string (hope im correct).


> Theres the start of an argument.  Check above in the post "About ADO
> connection?"  29/09/2001.  You'll get people arguing both methods (1
> connection vs. open them as you need them).  I think it depends on your
> particular situation.  What you connection limits are for the database,
how
> many users, etc... but that's just my opinion.  Most apparently believe in
> opening/closing as you need them.  But in my view that is way too slow if
> you can keep one connection open for each active user and use it for all
> your recordsets, why not (it's much faster)?  Anyhow check above for some
> opinions that are most likely better informed than mine.  Hope that helps
> Bill



> > Is it a good practice to open and close an ADO connection for each
> > select/Insert/Update statements? Or I should reuse the connection for
> every
> > select/Insert/Update statements?

 
 
 

Open/Close Connection String

Post by Evert Timme » Sat, 20 Oct 2001 14:21:10


If you connect using an ODBC connectionstring, the connections will be
pooled so there is no reason to keep it open. As soon as you open a "new"
connection, you will get one of the connections still in the pool.

For component development, this is the way to go. I can not remember ever
using a connection object in a component since i've always used a connection
string to open my recordsets directly.

HTH,
Evert

--
=======================================
My email address has been altered to
avoid unwanted email.

Replies to the newsgroup only, please.

Thanks,
Evert Timmer:
Transworld Software
VC++, VB6, SQL Server Database Solutions
http://www.transworld-software.com (under construction)
=======================================


Quote:> Is it a good practice to open and close an ADO connection for each
> select/Insert/Update statements? Or I should reuse the connection for
every
> select/Insert/Update statements?