How to use ADO to compress or repair Microsoft Access files

Source: Internet
Author: User
Tags ole reference access
When you used DAO, Microsoft provided CompactDatabase method to compress Microsoft Access files and RepairDatabase method to fix damaged Microsoft Access files. But since ADO came out, it seems like you forgot to provide the ability to compress and repair Microsoft Access files.

Now that Microsoft has found this problem, it also provides a way to understand, but there are limitations on the version! The restrictions are stated as follows:

ActiveX Data Objects (ADO), version 2.1
Microsoft OLE DB Provider for Jet, version 4.0

This is the extended feature of ADO that Microsoft has proposed: Microsoft Jet OLE DB Provider and Replication Objects (JRO)

This feature was first presented in JET OLE DB Provider version 4.0 (Msjetoledb40.dll) and JRO version 2.1 (Msjro.dll)!
These necessary DLL files are available after you install MDAC 2.1, and you can download the latest version of MDAC in the following pages!

Universal Data Access Web Site

Check out the VB6 before downloading, and the Microsoft Jet and Replication Objects x.x Library in the "control" "Set reference project" If it is already over 2.1, you can download it!

After you install MDAC 2.1 or more, you can use ADO to compress or repair Microsoft Access files, and the following steps tell you how to compress a Microsoft Access file using CompactDatabase method:

1. Create a new form and select "Control" in the menu and set the reference item.
2. Join Microsoft Jet and Replication Objects x.x Library (x.x is greater than or equal to 2.1).
3, in the appropriate place to add the following program code, remember to modify the data source content and the purpose of the file path:

Dim JRO as JRO. JetEngine
Set JRO = New JRO. JetEngine
Jro.compactdatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\nwind2.mdb", _ ' source file
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abbc2.mdb; Jet oledb:engine type=4 "' Destination file

After DAO 3.60, RepairDatabase method is no longer available, and the above program code shows the usage of ADO CompactDatabase method, and it replaces the DAO 3.5 repairdatabase met hod!







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.