We will introduce three methods for compressing and repairing databases.
Method 1:
Use DAO object)
Set Reference to the maxcompute project Microsoft Dao x. x Object Library
Currently, Dao has Microsoft Dao 3.51 Object Library (MDB before for Access 97) of version 3.5)
And Microsoft Dao 3.6 Object Library version 3.6 (for access 2 k followed by MDB)
You can also use the late binding method to create the dbengine of Dao 3.5 or 3.6 without specifying a reference (early binding ).
Set DBE = Createobject ("Dao. dbengine.35") 'or set DBE = Createobject ("Dao. dbengine.36 ")
The Compact billing intelligence (defragmentation) action is as follows:
Signature method:
Dbengine. compactdatabase olddb, newdb, locale, options, password
Olddb: Source MDB for processing
Newdb: MDB for processing
Locale metric data:
Dblanggeneral: English, German, French, Portuguese, Italian, and modern Spanish
Dblangchinesesimplified: Simplified Chinese (Traditional Chinese)
Dblangchinesetraditional: Traditional Chinese (Simplified Chinese)
Options values:
Dbversion10: M $ Jet DB Engine ver 1.0 file format while compacting.
Dbversion11: M $ Jet DB Engine ver 1.1 file format while compacting.
Dbversion20: M $ Jet DB Engine Ver 2.0 file format while compacting.
Dbversion30: M $ Jet DB Engine ver 3.0 file format (compatible with ver 3.5) while compacting.
Dbencrypt: encrypt the database while compacting.
Dbdecrypt: decrypt the database while Compacting
PS: jet (Joint engine technology)
Sample:
Dbengine. compactdatabase "C:/src. mdb", "C:/DST. mdb ",_
Dblangchinesetraditional, dbversion40 + dbencrypt
PS: dbversion40 can be upgraded to the ready version.
By the way, Dao 3.5 provides MDB repair (repair) methods:
Dbengine. repairdatabase "MDB path + region name"
PS: 3.5 this method is no longer available in the release version (compactdatabase has been merged)
========================================================== ======================================
Method 2:
Use jro objects
Set Reference to Microsoft Jet and replication objects x. x Library
Signature method:
Jetengine. compactdatabase (sourceconnection, destconnection)
Metric data:
Sourceconnection: string value, which specifies the connection to the source resource to be retrieved.
If the information specified by sourceconnection has been enabled, a response is generated.
Destconnection: string value. It specifies the connector for the destination information that is created only after the connection is established.
If the information specified by destconnection already exists or another case with the same name already exists, a response is generated.
Connection string:
Adequacy
Description
Provider
Indicates the provider's name, which is used to receive data from the source.
If this feature is not specified, the Microsoft. Jet. oledb.4.0 provider will be used.
If the provider name of the source string is different from the provider name of the destination string, a response is generated.
Data Source
Indicates the name of the resource.
Both source and destination regions require this flexibility.
User ID
Indicates the user's name when the source resource is set to secure.
Password
Indicates the user's password when the source data source is set to secure.
Locale identifier
Indicates the country ID of the new resource.
If this ID is omitted, the country ID of the destination data warehouse will be the same as the source data warehouse.
The sort order of country-specific data comparison strings.
Jet oledb: Database Password
Indicates the secret if the information is set to confidential.
Jet oledb: Engine type
Indicates the source resource version to be enabled or to be created.
You can use the following ole db engine types:
1 For jet Version 1.0
2 For jet version 1.1
3 For jet version 2.x
4 For jet version 3.x
5 For jet version 4.x
If the destination information is omitted, it is set to 5.
The value of the destination item cannot be a newer version than that of the source item.
Jet oledb: Registry path
Set the information of the Windows registry machine, including the Microsoft Jet Database Engine value.
Jet oledb: System Database
Indicates the location of the system resource.
Jet oledb: encrypt Database
Indicates whether to encrypt new data. If this parameter is omitted, the new data volume will be encrypted in the same way as the source data volume.
Jet oledb: Don't copy locale on compact
Indicates the sort order to be used by the information bank, replacing any other configuration for each item. (Boolean .)
Jet oledb: compact without relationships
Indicates whether to renew the service to a new resource. (Boolean .)
Jet oledb: compact without replica repair
Indicates whether to search for other copies to repair the hosted structured data. (Boolean .)
Sample:
Dim jro as new jro. jetengine
Jro. compactdatabase "provider = Microsoft. Jet. oledb.4.0; Data Source = source mdb ",_
"Provider = Microsoft. Jet. oledb.4.0; Data Source = destination MDB; Jet oledb: Engine type = 4"
========================================================== ======================================
Method 3:
If the machine has access M $ access, you can also directly use access to repair/compact MDB resources.
Or the login program calls access to do it.
Create an Access Application Object
Set Reference to Microsoft Access x. x Object Library
Dim objacc as new access. Application
Or
Dim objacc as object
Set objacc = Createobject ("access. application ")
After
Call objacc. compactrepair ("C:/a. mdb", "C:/B. mdb", false)
You can.
========================================================== ======================================