+ -
当前位置:首页 → 问答吧 → 请教:如何实现对access2003的数据库压缩?

请教:如何实现对access2003的数据库压缩?

时间:2011-08-10

来源:互联网

现在所知的代码只对access2000的有效,但是对于2003的不行。
大家有什么好的解决办法吗?

作者: snui007   发布时间: 2011-08-10

'数据库压缩
defDatabasePath=“/db/”
dbpath=“db.mdb”
Call smart_compactdata()

sub smart_compactdata()
    on error resume next
    dbpath = Server.MapPath(defDatabasePath&defDatabase)
    compactpath = server.MapPath(defDatabasePath)&" emp.mdb"
    set fso = Server.CreateObject("Scripting.FileSystemObject")
    if Err <> 0 Then
        response.write "该空间不支持FSO组件,操作失败"
    else
        If fso.FileExists(dbPath) Then
            set Engine = CreateObject("JRO.JetEngine")
            set conn=nothing
            Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath," Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & compactpath
            fso.CopyFile compactpath,dbpath
            fso.DeleteFile(compactpath)
            set fso = nothing
            set Engine = nothing
        Else
            response.write "找不到数据库文件"
        End if
    End if
end sub

作者: Avram   发布时间: 2011-08-10