1. 在项目中添加引用msjro.dll(c:\program files\comm files\System\ado\msjro.dll);
2. 引用 using JRO;
3.实现
Dim Path1 As String, Path2 As String, DbConn1 As String, DbConn2 As String
Path1 = Server.MapPath("aa.mdb") '原数据库
Path2 = Server.MapPath("db2.mdb") '压缩后的数据库
DbConn1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path1
DbConn2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path2
Dim DatabaseEngin As JetEngine = New JetEngine()
DatabaseEngin.CompactDatabase(DbConn1, DbConn2) '压缩
File.Copy(Path2, Path1, True) '将压缩后的数据库覆盖原数据库
File.Delete(Path2) '删除压缩后的数据库