要引用这个com对象
点机 项目 =-》 添加引用 -》会出现一个选项卡 -》 选择com -》 选择游览 -》 在把
msjro.dll 引用近来就可以了 ~~~(用 ctrl + alt + j 看 对象游览器 可以看见 )interop.jro路径 C:\Program Files\Common Files\System\ado\msjro.dll using JRO;
JetEngine x = new JetEngine();
x.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb;","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\aa\\aa.mdb;Jet OLEDB:Database Password=aaa");原先 数据库 test.mdb 160k 没有密码 ,压缩后 124k 密码为aaa
点机 项目 =-》 添加引用 -》会出现一个选项卡 -》 选择com -》 选择游览 -》 在把
msjro.dll 引用近来就可以了 ~~~(用 ctrl + alt + j 看 对象游览器 可以看见 )interop.jro路径 C:\Program Files\Common Files\System\ado\msjro.dll using JRO;
JetEngine x = new JetEngine();
x.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb;","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\aa\\aa.mdb;Jet OLEDB:Database Password=aaa");原先 数据库 test.mdb 160k 没有密码 ,压缩后 124k 密码为aaa
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With ' Make sure there isn't already a file with the
' name of the compacted database.
If Dir("NwindKorean.mdb") <> "" Then _
Kill "NwindKorean.mdb" ' This statement creates a compact version of the
' Northwind database that uses a Korean language
' collating order.
DBEngine.CompactDatabase "Northwind.mdb", _
"NwindKorean.mdb", dbLangKorean Set dbsNorthwind = OpenDatabase("NwindKorean.mdb") ' Show the properties of the compacted database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End WithEnd SubThis example uses the CompactDatabase method to change the version of a database. To run this code, you must have a Microsoft Jet version 1.1 database called Nwind11.mdb and you cannot use this code in a module belonging to Nwind11.mdb.Sub CompactDatabaseX2() Dim dbsNorthwind As Database
Dim prpLoop As Property Set dbsNorthwind = OpenDatabase("Nwind11.mdb") ' Show the properties of the original database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With ' Make sure there isn't already a file with the
' name of the compacted database.
If Dir("Nwind20.mdb") <> "" Then _
Kill "Nwind20.mdb" ' This statement creates a compact and encrypted
' Microsoft Jet 2.0 version of a Microsoft Jet version
' 1.1 database.
DBEngine.CompactDatabase "Nwind11.mdb", _
"Nwind20.mdb", , dbEncrypt + dbVersion20 Set dbsNorthwind = OpenDatabase("Nwind20.mdb") ' Show the properties of the compacted database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
For Each prpLoop In .Properties
On Error Resume Next
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
On Error GoTo 0
Next prpLoop
.Close
End WithEnd Sub