ACCESS数据库的压缩,备份,还原,下载,删除的实现

复制代码 代码如下:

<html>

<head>

<meta http-equiv=”content-language” content=”zh-cn”>

<meta http-equiv=”content-type” content=”text/html; charset=gb2312″>

<title>数据库管理</title>

</head>

<body>

<div align=center>数据库管理系统</div>

<br>

<br>

<p align=”center”>

<%

dim zc_database_path

‘数据库的路径

zc_database_path=”database/data.mdb”

data_array= split(zc_database_path,”/”)

dim action

action=trim(request(“action”))

dim dbpath,bkfolder,bkdbname,fso,fso1

select case action

case “”

call chushihua()

case “compressdata” ‘压缩数据

dim tmprs

dim allarticle

dim maxid

dim topic,username,dateandtime,body

call compressdata()

case “backupdata” ‘备份数据

if request(“act”)=”backup” then

call updata()

else

call backupdata()

end if

case “restoredata” ‘恢复数据

dim backpath

if request(“act”)=”restore” then

dbpath=request.form(“dbpath”)

backpath=request.form(“backpath”)

if dbpath=”” then

response.write “please input your database whole name” 

else

dbpath=server.mappath(dbpath)

end if

backpath=server.mappath(backpath)

set fso=server.createobject(“scripting.filesystemobject”)

if fso.fileexists(dbpath) then 

fso.copyfile dbpath,backpath

response.write “数据库被成功还原!<br>”

else

response.write “没找到您所需要的数据库!” 

end if

else

call restoredata()

end if

case “spacesize” ‘系统空间占用

call spacesize()

case “deletebackup”

dim dbname

dbpath=request.querystring(“dbpath”)

dbname=request.querystring(“dbname”)

dbpath=server.mappath(dbpath)

dbpath=dbpath &”\”&dbname

set fso = createobject(“scripting.filesystemobject”)

if fso.fileexists(dbpath) then

fso.deletefile(dbpath)

set fso = nothing

response.write “<br>您备份的数据库已经” & dbpath &”被成功删除!<br><br><a href=””data_s.asp””>返回..</a>”

else

response.write dbpath 

response.write “<br>输入的路径错误,请确认后重新输入!<br><br><a href=””data_s.asp””>返回..</a>”

end if

case else

end select

%>

</div>

<%

response.write”</body></html>”

sub chushihua()

%>

<div align=center>

<form id=”edit”>

<br/>

<a href=”?action=compressdata”>[压缩数据库]</a>

<br/><br/><a href=”?action=backupdata”>[备份数据库]</a>

<br/><br/><a href=”?action=restoredata”>[还原数据库]</a>

<br/><br/><a href=”?action=spacesize”>[系统空间占用]</a>

<br/><br/>

</form>

</div>

<%end sub%>

<%

‘====================系统空间占用=======================

sub spacesize()

on error resume next

%>

<div align=center>

<div align=center>

系统空间查看

<br/><br/>

<form id=”edit”>

<br>

数据库:<%showspaceinfo(“../”&data_array(1)&””)%><br><br>

备份数据库:<%showspaceinfo(“databackup”)%><br><br>

系统总共:<%showspaceinfo(“/”)%>

<br><br>

</form>

</div>

<br >

<br >

<br >

<a href=”data_s.asp”>返回…</a>

</div> 

<%

end sub

%>

<% sub showspaceinfo(drvpath)

dim fso,d,size,showsize

set fso=server.createobject(“scripting.filesystemobject”) 

drvpath=server.mappath(drvpath) 

set d=fso.getfolder(drvpath) 

size=d.size

showsize=size & ” byte” 

if size>1024 then

size=(size/1024)

showsize=size & ” kb”

end if

if size>1024 then

size=(size/1024)

showsize=formatnumber(size,2) & ” mb” 

end if

if size>1024 then

size=(size/1024)

showsize=formatnumber(size,2) & ” gb” 

end if 

response.write “<font face=verdana>” & showsize & “</font>”

end sub 

%>

<%

sub restoredata()

%>

<div align=center>

<div align=center>

<br/><…

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐