Closing ODBCConnections

Z

zacks

If I close and dispose an ODBCConnection object, shouldn't the
connection actually close? I have found that even after closing and
disposing an ODBCConnection, the database it was connected to still
has an active connection as long as the application is still running.
I have to close the application to actually close the active
connection to the database. Is this normal behaviour? Is there a way
to really close the connection while the application is still running?
 
S

Sambantham Kuppusamy

Yes it is. The ODBC connection is a pool and will be active for some time
usually 15 minutes and another request can use it.
This is how ODBC works and when the application is closed normally all the
pooled ODBC connections are closed.
 
R

rowe_newsgroups

Yes it is. The ODBC connection is a pool and will be active for some time
usually 15 minutes and another request can use it.
This is how ODBC works and when the application is closed normally all the
pooled ODBC connections are closed.

If I'm not mistaken, doesn't calling GC.Collect() also clear out the
ODBC connection pool?

Thanks,

Seth Rowe
 
S

Sambantham Kuppusamy

if you use Oledb connection using ADO.net instead of odbc you can have a
better control of closing the connections yourself.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Sambantham said:
if you use Oledb connection using ADO.net instead of odbc you can have a
better control of closing the connections yourself.

What is the difference ?

Docs for OdbcConnection say:

Note
To deploy high-performance applications, you frequently must use
connection pooling. However, when you use the .NET Framework Data
Provider for ODBC, you do not have to enable connection pooling because
the provider manages this automatically.

Docs for OleDbConnection says:

Note
To deploy high-performance applications, you must use connection
pooling. When you use the .NET Framework Data Provider for OLE DB, you
do not have to enable connection pooling because the provider manages
this automatically.

The wording is slightly different, but the substance seems identical.

Arne
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

rowe_newsgroups said:
If I'm not mistaken, doesn't calling GC.Collect() also clear out the
ODBC connection pool?

GC releases memory for objects that are unreachable.

The connections is a connection pool are obvious
reachable.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top