<%if Session("weight")<>5 then 
Response.Redirect "error.asp?cause=4"
 end if
%><html>
<head>
<link rel="stylesheet" href="../images/css.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>数据库压缩</title>
</head>
<body bgcolor="#ffffff">
&nbsp;<table cellpadding=0 cellspacing=0 border=0 width=100% align=center>
  <tr>
    <td>
      <table cellpadding=3 cellspacing=1 border=0 width=100%>
        <tr>
        <td>
                        <p align="center">数据库压缩
        </td>
        </tr>
            <tr>
              <td width="100%" valign=top><p align="center">
&nbsp;<table width=100% cellspacing=1 cellpadding=0>
<form action=mdbchear.asp>
<tr>
<td><b><font color="red">注意：</font></b><br>输入数据库所在相对路径,并且输入数据库名称（正在使用中数据库不能压缩，请选择备份数据库进行压缩操作） <br><b><font color="red">注意：</font><br></b>压缩数据库会占用大量系统资源，请在流量少的时候进行压缩！</td>
</tr>
<tr>
<td>压缩数据库：<input type="text" name="dbpath" value="..\db\sjxffriend.asa">&nbsp;
<input type="submit" value="开始压缩"></td>
</tr>
<form>
</table>
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

If dbpath <> "" Then
dbpath = server.mappath(dbpath)
	response.write(CompactDB(dbpath,boolIs97))
End If
%>
</p></font></td>
            </tr>
        </table>
        </td>
    </tr>
</table>
<%
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
%>