So I've got a program that uses an MS Access 2000 database. If I have a program crash or system reboot sometimes the database gets damaged. When I open the DB with VB6 and get a message "Unrecognized database format ". When I run the VB6 database repair/compact routine - no luck. I even tried using the JRO repair/compact - no luck. Visdata can't open/compact/repair the database either. I downloaded JETCOMP.EXE from Microsoft - no luck there either.
But when I open it with Access 2007 - it says "Database has been left in an inconsistent state" and then promptly fixes it no problem at all.
Is there any way to reliably repair the Database in VB6?
Any help appreciated!
Here's the JRO repair that didn't work. I get error: -2147467259 Unrecognized database format - (I have all the references and passwords and DB names right):
'Project Reference : Microsoft Jet and Replication Objects 2.6 Library
'Tables must be closed
Dim MyJRO As JRO.JetEngine
Set MyJRO = New JRO.JetEngine
If Dir(App.Path & "\MyMDBOTemp.mdb", vbArchive) <> "" Then
Kill App.Path & "\MyMDBTemp.mdb"
End If
GStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyMDB.mdb;Jet OLEDB:Database Password=xxxx;"
GStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyMDBTemp.mdb;Jet OLEDB:Database Password=xxxx;"
MyJRO.CompactDatabase GStr1, GStr2
Kill App.Path & "\MyMDB.mdb"
FileCopy App.Path & "\MyMDBTemp.mdb", App.Path & "\MyMDB.mdb"
Set MyJRO = Nothing
But when I open it with Access 2007 - it says "Database has been left in an inconsistent state" and then promptly fixes it no problem at all.
Is there any way to reliably repair the Database in VB6?
Any help appreciated!
Here's the JRO repair that didn't work. I get error: -2147467259 Unrecognized database format - (I have all the references and passwords and DB names right):
'Project Reference : Microsoft Jet and Replication Objects 2.6 Library
'Tables must be closed
Dim MyJRO As JRO.JetEngine
Set MyJRO = New JRO.JetEngine
If Dir(App.Path & "\MyMDBOTemp.mdb", vbArchive) <> "" Then
Kill App.Path & "\MyMDBTemp.mdb"
End If
GStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyMDB.mdb;Jet OLEDB:Database Password=xxxx;"
GStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyMDBTemp.mdb;Jet OLEDB:Database Password=xxxx;"
MyJRO.CompactDatabase GStr1, GStr2
Kill App.Path & "\MyMDB.mdb"
FileCopy App.Path & "\MyMDBTemp.mdb", App.Path & "\MyMDB.mdb"
Set MyJRO = Nothing