如何清除 OleDbConnection 的连接池
我使用 OleDatabase 连接连接到 Access 数据库。问题是我需要以编程方式对数据库运行压缩和修复操作,但是当仍然存在与数据库的打开连接时我无法执行此操作。存在的连接当然是来自我的程序的连接池的连接,但是我似乎无法弄清楚如何清除池以便我可以运行压缩和修复。
我确实对打开数据库的所有连接都有一个 using 语句,所以问题不是我没有正确处理连接,问题是连接池。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
OleDbConnection
上调用静态方法ReleaseObjectPool
- 请参阅 http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspxCall the static method
ReleaseObjectPool
on the theOleDbConnection
- see http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspx