Hi

Anyone know how to correct a currupted database using vb code? Please help me out to solve........

Have you tried doing this manually?

Hi,

Use This Code:
Repairs C:\DB1.mdb

Dim TempStr As String
Dim OrigStr As String
OrigStr = "C:\DB1.mdb"
TempStr ="C:\DBTemp.mdb"
'
On Error Resume Next
Kill TempStr
DBEngine.RepairDatabase OrigStr, TempStr
Kill OrigStr
FileCopy TempStr, OrigStr
Kill TempStr

Msgbox "Repaired Successfully"

Regards
Veena

Microsoft access 2003 has a wizard to repair databases built - in this only recovers tables though, forms and reports get lost

In most cases MS-Access inbuilt utilities recover these kind of corrupted databases, but its not guaranteed that it can your database too.

For this problem one software comes in my mind Stellar Phoenix Access Recovery it will help you to recover data which is not accessible due to corruption in Access databases, Tables, Queries, Forms, or Reports.

Just try free trial version <url snipped> it will scan your database and after that you will be able to see your recovered database.

If you are pleased with that buy full version of this software so that you can save your recovered database.

You can use following method and code to recover corrupted database.

1.DBEngine.CompactDatabase strInput strOutput

This compacts the database. strInput is the database file to be actioned on and strOutput is the resultant compacted database file name.

2. DBEngine.RepairDatabase strInput

This repairs a database. A trapable error 3049 can be checked for. This error indicates the database is possibly corrupt and therefore RepairDatabase method can be implemented.

To open a database exclusively:

Set db = dbEngine.Workspaces(0).OpenDatabase (strDBase,True)

If still errors comes, it means database is critically corrupt. You should have backup of this database file or use some good access repair software like Stellar Phoenix access recovery. This supports all version of microsoft access and in demo version you can check your repaired database.

Good Luck

You can use following method to recover corrupted database.

1. To compacts the database.
DBEngine.CompactDatabase strInput strOutput

strInput is the database file to be actioned on and strOutput is the resultant compacted database file name.

2. To repairs a database.
DBEngine.RepairDatabase strInput

3. To open a database exclusively:
Set db = dbEngine.Workspaces(0).OpenDatabase (strDBase,True)

If still you face the errors, it means database is critically corrupted. To repair your database you need the third party access database repair software.

Edited 7 Years Ago by Davidpoul: n/a

This article has been dead for over six months. Start a new discussion instead.