www.gusucode.com > 掌柜网店购物系统 4.0码程序 > admin/compress.asp

    <!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>2 then
response.Write "<p align=center><font color=red>您没有此项目管理权限!</font></p>"
response.End
end if
end if
%>
<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../img/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
    <td align="center" bgcolor="#dfdfdf"><b>压缩数据库 ( 需要FSO支持,FSO相关帮助请看微软网站 
      ) </font></b></td>
</tr>
<tr>
    <td width=100% bgcolor=#f2f2f2> <font color=red>注意:输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作)</font> 
    </td>
</tr>
    <td bgcolor="#f2f2f2"><tr>
<%

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
%>
<form name="compress" method="post" action="compress.asp">
<td width=100% bgcolor=#f2f2f2>
压缩数据库:<input type="text" name="dbpath" size="20" value="../data/shop.mdb">
<input type="submit" name="submit" value="开始压缩">
</td>
      <td bgcolor="#f2f2f2"></tr>
<tr>
      <td width=100% bgcolor=#f2f2f2> 
        <input type="checkbox" name="boolIs97" value="True">
        如果使用 Access 97 数据库请选择(默认为 Access 2000 数据库) </td>
</tr>
</form>

<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

If dbpath <> "" Then
       dbpath = server.mappath(dbpath)
       response.write(CompactDB(dbpath,boolIs97))
End If
%>
    <td bgcolor="#f2f2f2"></td>
    <td bgcolor="#f2f2f2"></tr></table>
<!--#include file="copyright.asp"-->
</body>
</html>