⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compressdata.asp

📁 为一网站销售代码
💻 ASP
字号:
<!--#include file="conn.asp"-->

<% if session("IsAdmin")<>true then 
	Response.Redirect "notlogin1.htm"
	else
	if session("loginpass")<>true then
		Response.Redirect "notlogin.htm" 
	else
		dim tmprs,rs
		dim allarticle
		dim Maxid
		dim topic,username,dateandtime,body
		call main()
		set rs=nothing
		conn.close
		set conn=nothing
     end if
sub main()
%><head>
<title>压缩数据库</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<BODY >

<table class=tableborder1 cellspacing=1 cellpadding=1 align=center>
<form action=CompressData.asp>
<tr>
<td class=tablebody1 height=25><b>压缩数据库--注意:</b><br>输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) <br>请先把原数据库备份、改名为card.mdb然后再压缩。压缩完后把原数据库改为其他名字,再把压缩好的库改名为<br>card.asp即可</td>
</tr>
<tr>
<td class=tablebody1>压缩数据库:<input type="text" name="dbpath" value=Data\card.mdb>&nbsp;                        
<input type="submit" value="开始压缩"></td>                        
</tr>                        
<tr>                        
<td class=tablebody1><input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择                        
(默认为 Access 2000 数据库)<br><br></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                        
	end sub                        
%>                        
<%                        
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                        
end if     
%>                        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -