admin_compact.asp
来自「CityCN V2.1 是自主开发的基于ASP+Access的新型资讯信息系统。」· ASP 代码 · 共 73 行
ASP
73 行
<%option explicit%>
<!--#include file="config.asp" -->
<!--#include file="conn.asp" -->
<!--#include file="admin_admininfo.asp"-->
<%
if session("adminname")<>adminname or session("adminpwd")<>adminpwd then
response.Redirect("admin_login.asp")
end if
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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="admin.css" rel="stylesheet" type="text/css">
<title>【后台管理】压缩ACCESS数据库 - <%=sitename%></title>
</head>
<body leftmargin="0" topmargin="0">
<!--#include file="admin_top.asp" -->
<br>
<h2 align="center">压缩ACCESS数据库</h2>
<p align="center">
<form action="compact.asp" method="POST" target="_blank">
请输入数据库的相对路径,包括数据名.
<p align="center"><input type="text" name="dbpath" size="31" value="<%=db%>"><br>
<input type="checkbox" name="boolIs97" value="True">如果是Access 97 数据库请选择这里(默认是 Access 2000)<br>
<br>
<br>
<a href="<%=db%>"><%=db%></a>
<br>
<br>
<input type="submit" value="开始压缩" name="begin"></p>
<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>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?