CompactDatabase Jet 4.0

I keep getting unrecognized database format when I try to compact a Jet 4.0 database within  a VB programme.
How do I get it to work?
gregbinnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leesssCommented:
Can you open a Jet 4.0 db first?
0
gregbinnsAuthor Commented:
Yes I can open recordsets etc. no trouble.
0
jetforceCommented:
What DAO library are you using? Is it 3.6 or 3.5?
0
DedushkaCommented:
Hi gregbinns.
You can compact Jet 4.0 databases using CompactDatabase Method of JetEngine object from Jet and Replication Objects (JRO).
Here is code taken directly from MSJRO.CHM help file:

CompactDatabase Method Example
This example demonstrates how to compact and encrypt a database with the CompactDatabase method.

Public Sub CompactAndEncrypt()

    Dim je As New JRO.JetEngine

    ' Make sure that a file doesn't exist with the name of
    ' the compacted database.
    If Dir("C:\Program Files\Microsoft Office\" & _
        "Office\Samples\Northwind2.mdb") <> "" Then Kill _
        "C:\Program Files\Microsoft Office\Office\Samples\Northwind2.mdb"

    ' Compacts and encrypts version Northwind database.
    je.CompactDatabase _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\Program Files\Microsoft Office\" & _
        "Office\Samples\Northwind.mdb", _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\Program Files\Microsoft Office\" & _
        "Office\Samples\Northwind2.mdb;" & _
    "Jet OLEDB:Encrypt Database=True"

End Sub

Best regards,
Dedushka
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.