PHP: <% option explicit Const JET_3X = 4 Function CompactDB(dbPath, boolIs97) Dim fso, Engine, strDBPath strDBPath = left(dbPath,instrrev(DBPath,"\")) Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(dbPath) Then Set Engine = CreateObject("JRO.JetEngine") If boolIs97 = "True" Then Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _ & "Jet OLEDB:Engine Type=" & JET_3X Else Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb" End If fso.CopyFile strDBPath & "temp.mdb",dbpath fso.DeleteFile(strDBPath & "temp.mdb") Set fso = nothing Set Engine = nothing CompactDB = "你的数据库, " & dbpath & ", 已经被压缩.!" & vbCrLf Else CompactDB = "数据库名字不正确!" & vbCrLf End If End Function %> <html><head><title>Compact Database</title></head><body> <h2 align="center"> 压缩数据库</h2> <p align="center"> <form action=compact.asp> Enter relative path to the database, including database name.<br><br> <input type="text" name="dbpath"><br><br> <input type="checkbox" name="boolIs97" value="True"> 如果是ac97,请打上勾 <br><i> (默认是Access 2000以后的版本)</i><br><br> <input type="submit"> <form> <br><br> <% Dim dbpath,boolIs97 dbpath = request("dbpath") boolIs97 = request("boolIs97") If dbpath <> "" Then dbpath = server.mappath(dbpath) response.write(CompactDB(dbpath,boolIs97)) End If %> </p></body></html>