如何以编程方式修复(不仅仅是紧凑)Access .mdb文件?

时间:2023-01-15 08:16:54

I have a corrupt database. If I open it in MS Access, MS Access offers to repair it, and it succeeds.

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

How can I do that with code? On a machine where MS Access is not installed.

我怎么能用代码呢?在未安装MS Access的计算机上。

I know from trying it that JRO.JetEngine.CompactDatabase does NOT work.

我从尝试它知道JRO.JetEngine.CompactDatabase不起作用。

In other words, I want to do what Access or JETCOMP.exe is doing, not what JRO.JetEngine.CompactDatabase is doing.

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

4 个解决方案

#1


2  

You need to go to http://support.microsoft.com and search for the JetComp.exe utility, which will attempt to repair and compact your MDB without opening the file. The reason none of the suggestions above work is because they have to open the MDB to do their work, whereas JetComp doesn't open the file, but operates on it structurally.

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

If it can't recover your file (which does happen), then you'll have to go to a data recovery service. I recommend Peter Miller of PKSolutions.com.

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

#2


1  

Command-line switch for opening a .mdb file:

用于打开.mdb文件的命令行开关:

/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.

如果在/ compact开关后省略目标文件名,则会将文件压缩为原始名称和文件夹。要压缩为其他名称,请指定目标文件。

#3


1  

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

你试过DBEngine.RepairDatabase [my.mdb]吗? (即使您引用早期版本,它似乎也不再起作用)

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.

如果您愿意使用单独的实用程序,Jetcomp.exe实用程序(http://support.microsoft.com/kb/295334)如何。它应该“能够恢复Microsoft Access压缩实用程序和CompactDatabase方法无法恢复的某些数据库”。在这种情况下,您需要做的就是执行外部应用程序。

e.g.,

Call Shell("Jetcomp.exe <arguments>")

#4


0  

I'm not a MS Acccess guru, but it appears as though this utility contains the DLLs you'd need to compact and repair a corrupt database file.

我不是MS Acccess大师,但似乎这个实用程序包含您需要压缩和修复损坏的数据库文件的DLL。

#1


2  

You need to go to http://support.microsoft.com and search for the JetComp.exe utility, which will attempt to repair and compact your MDB without opening the file. The reason none of the suggestions above work is because they have to open the MDB to do their work, whereas JetComp doesn't open the file, but operates on it structurally.

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

If it can't recover your file (which does happen), then you'll have to go to a data recovery service. I recommend Peter Miller of PKSolutions.com.

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

#2


1  

Command-line switch for opening a .mdb file:

用于打开.mdb文件的命令行开关:

/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.

如果在/ compact开关后省略目标文件名,则会将文件压缩为原始名称和文件夹。要压缩为其他名称,请指定目标文件。

#3


1  

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

你试过DBEngine.RepairDatabase [my.mdb]吗? (即使您引用早期版本,它似乎也不再起作用)

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.

如果您愿意使用单独的实用程序,Jetcomp.exe实用程序(http://support.microsoft.com/kb/295334)如何。它应该“能够恢复Microsoft Access压缩实用程序和CompactDatabase方法无法恢复的某些数据库”。在这种情况下,您需要做的就是执行外部应用程序。

e.g.,

Call Shell("Jetcomp.exe <arguments>")

#4


0  

I'm not a MS Acccess guru, but it appears as though this utility contains the DLLs you'd need to compact and repair a corrupt database file.

我不是MS Acccess大师,但似乎这个实用程序包含您需要压缩和修复损坏的数据库文件的DLL。