Access “Compact and Repair” programmatically

前端 未结 7 599
逝去的感伤
逝去的感伤 2020-12-03 22:28

Is it possible to \"compact and repair\" an Access database programmatically somehow (using ADOX, using OleDbConnection etc.)?

相关标签:
7条回答
  • 2020-12-03 23:02

    it'possible compacting and repairing an MS ACCESS database in two ways:

    • using DAO: in DAO350 there's a method RepairDatabase(), while in DAO360 there's CompactDatabase()
    • using MDAC+JRO:

    As an example, in VB6 (old, old, old...) do this:

    Dim jro As jro.JetEngine
    Set jro = New jro.JetEngine
    jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db_to_repair.mdb;Jet OLEDB:Database Password=mypass", _ 
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\repaired_db.mdb;Jet OLEDB:Engine Type=4;Jet OLEDB:Database Password=mypass"
    

    As you will notice, the function requires that you specify the name of the db to be repaired and the name of the repaired database.

    0 讨论(0)
提交回复
热议问题