How can I programmatically repair (not merely compact) an Access .mdb file?

后端 未结 4 1236
渐次进展
渐次进展 2021-01-15 13:48

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

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 14:40

    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 ")
    

提交回复
热议问题