如何强制关闭OleDBConnection的句柄到JET 4.0数据库 [英] How to force a handle close of an OleDBConnection to a JET 4.0 database
问题描述
问候
 我有一个用VB编写的.NET 3.5框架程序,它首先以共享模式打开Microsoft Access文件。稍后,该程序希望获得独占访问权限,因此我关闭该文件,然后尝试以独占模式重新打开它。
不一致我无法重新打开文件,说有人(正在运行的程序!)已经打开文件,所以我无法以独占模式打开它。
在尝试重新打开文件之前关闭文件的例程中,我关闭了oledbconnection,一个dispose,然后我甚至将oledbconnection设置为空。
如果我从sysinternals启动句柄,它说我仍然打开文件句柄。如何一直得到关闭的句柄,以便我可以独家重新打开文件!我看到了一个可能是连接池的建议,但是如建议的那样将ole db service参数设置为-4没有任何效果。
谢谢
委员Scott
Greetings
I have a .NET 3.5 framework program written in VB that at first opens a Microsoft Access file in shared mode. Later on, the program wants to gain exclusive access, so I have it close the file, then attempt to reopen it in exclusive mode.
Inconsistently I am unable to re-open the file, saying that someone (the program that's running!) has the file open already, so I can't open it in exclusive mode.
In the routine that closes the file before the attempt to reopen it, I have a close of the oledbconnection, a dispose, then I even set the oledbconnection to nothing.
If I fire up handle from sysinternals, it says I still have the file handle open. How does one consistently get that handle to close so I can reopen the file exclusively! I saw a suggestion that it might be connection pooling, but setting the ole db service parameter to -4 as suggested had no effect.
Thanks
Scott
推荐答案
Hello Scott ,
欢迎来到ADO.NET数据提供商论坛!
您使用的是数据驱动程序Microsoft.Jet.OLEDB.4.0吗? 我创建了一个演示项目并测试了OleDbConnection.Close()。 它工作正常,调用.Close()方法后释放文件句柄。 我建议您通过 解决此问题 Process Explorer 。 此工具可以帮助我们检查某些流程打开的文件句柄。
Are you using the data driver Microsoft.Jet.OLEDB.4.0? I create a demo project and tested the OleDbConnection.Close(). It works fine and the file handle is released after the .Close() method is called. I recommend you troubleshoot this problem by Process Explorer. This tool can help us to check what file handles are opened by certain process.
1.   ;     打开Process Explorer。
1. Open the Process Explorer.
2. 按"Ctrl + H"键;查看所有句柄。
3. ;   按"Ctrl + F"键;通过Access数据库文件名搜索句柄列表,例如myAccess.mdb。
然后我们将找到哪个进程保存Access数据库文件的文件句柄。
< span style ="font-size:12pt"> 此外,您能否提供一些详细步骤或示例代码来重现此问题?  ;&NBSP; 非常感谢!
度过美好的一天!
最诚挚的问候,郎灵芝
MSDN订阅者支持 在论坛
如果您对我们的支持有任何反馈,请联系 msdnmg@microsoft.com
If you have any feedback on our support, please contact msdnmg@microsoft.com
这篇关于如何强制关闭OleDBConnection的句柄到JET 4.0数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!