Matthew Sanford
Matthew Sanford

Reputation: 1099

How to clear the connection pool for an OleDbConnection

I am connection to an Access Database using a OleDatabase Connection. The problem is that I need to programmatically run the compact and repair operation on the database, however I can not do this while there are still open connections to the database. The connections that exist are of course the connections from the connection pool from my program, however I can not seem to figure out how to clear the pool so that I can run the compact and repair.

I do have a using statement on all connections that get opened to the database so the problem is not that I am not disposing of the connections properly, the problem is the connection pool.

Upvotes: 3

Views: 3724

Answers (1)

Yahia
Yahia

Reputation: 70369

Call the static method ReleaseObjectPool on the the OleDbConnection - see http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspx

Upvotes: 4

Related Questions