1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

access 数据库可以在线压缩吗?

本帖由 Sunya2006-05-12 发布。版面名称:后端开发

  1. Sunya

    Sunya Member

    注册:
    2005-09-09
    帖子:
    954
    赞:
    1
    用 TSQL 语句!
     
  2. Tameway

    Tameway New Member

    注册:
    2005-09-06
    帖子:
    1,286
    赞:
    8
    可以,很多程序都有这个功能的,例如L-BLOG
    找他的看看
     
  3. shu_yu

    shu_yu New Member

    注册:
    2006-03-19
    帖子:
    355
    赞:
    0
    可以的,代码和说明见下:
    compact.asp
    <%
    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>
    <body>
    精彩春风之在线压缩Access数据库
    <p align="center">
    <form action=compact.asp>
    请输入数据库的相关路径、名称: <br><br>
    <input type="text" name="dbpath"><br><br>
    <input type="checkbox" name="boolIs97" value="True"> 检查是否Access 97 (默认为Access 2000) <br>
    <input type="submit" value="开始压缩">
    <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>