2

我有一个损坏的数据库。如果我在 MS Access 中打开它,MS Access 会提供修复它,它会成功。

我怎么能用代码做到这一点?在未安装 MS Access 的机器上。

我通过尝试知道 JRO.JetEngine.CompactDatabase 不起作用。

换句话说,我想做 Access 或 JETCOMP.exe 正在做的事情,而不是 JRO.JetEngine.CompactDatabase 正在做的事情。

4

4 回答 4

2

您需要访问http://support.microsoft.com并搜索 JetComp.exe 实用程序,该实用程序将尝试在不打开文件的情况下修复和压缩您的 MDB。上述建议都不起作用的原因是因为他们必须打开 MDB 才能完成工作,而 JetComp 不会打开文件,而是在结构上对其进行操作。

如果它无法恢复您的文件(确实发生了),那么您将不得不去数据恢复服务。我推荐 PKSolutions.com 的 Peter Miller。

于 2008-09-27T22:57:25.263 回答
1

Command-line switch for opening a .mdb file:

/compact

It repairs and compacts the database file.

If you leave out a target file name following the /compact switch, the file is compacted to the original name and folder. To compact to a different name, specify a target file.

于 2008-09-26T20:43:47.277 回答
1

Have you tried DBEngine.RepairDatabase [my.mdb]? (which doesn't seem to work any more even when you reference an earlier version)

However, if is happening so often that you need to code it, you probably have a bigger problem you should be solving first.

If you are willing to use separate utility, how about the Jetcomp.exe utility (http://support.microsoft.com/kb/295334 ). It is supposed to "be able to recover some databases that the Microsoft Access compact utility and the CompactDatabase method cannot." In which case, all you need to do is execute the external application.

e.g.,

Call Shell("Jetcomp.exe <arguments>")
于 2008-09-26T20:48:00.667 回答
0

我不是 MS Acccess 专家,但看起来这个实用程序包含压缩和修复损坏的数据库文件所需的 DLL。

于 2008-09-26T20:40:47.597 回答