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

📄 database.asp

📁 word习题 word习题 word习题
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%@ LANGUAGE=VBScript CodePage=936%>
<%
option explicit
response.buffer=true	
Const strDBPath = "Databackup\"
%>
<!--#include file="bsconfig.asp"-->
<%
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
dim dbpath
dim ObjInstalled
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
%>
<!-- #include file="Inc/Head.asp" -->

<BR>
<table cellpadding="2" cellspacing="1" border="0" width="600" align="center" class="a2">
	<tr>
		<td class="a1" height="25" align="center" colspan="2"><strong>数 据 库 管 理</strong></td>
	</tr>
	<tr class="a4">
		<td width="75" height="30">&nbsp;<strong>管理导航:</strong></td>
    <td height="30">&nbsp;<a href="Database.asp?Action=Backup">备份数据库</a> | <a href="Database.asp?Action=Restore">恢复数据库</a> | <a href="Database.asp?Action=Compact">压缩数据库</a> | <a href="Database.asp?Action=SpaceSize">系统空间占用情况</a>
		</td>
	</tr>
</table>
<BR>

<%
if InStr(request("db"),".asp")>0 or InStr(request("db"),".asa")>0 or InStr(request("db"),".cer")>0 or InStr(request("db"),".cdx")>0 or InStr(request("bkfolder"),".asp")>0 or InStr(request("bkfolder"),".asa")>0 or InStr(request("bkfolder"),".cer")>0 or InStr(request("bkfolder"),".cdx")>0 or InStr(request("bkDBname"),".asp")>0 or InStr(request("bkDBname"),".asa")>0 or InStr(request("bkDBname"),".cer")>0 or InStr(request("bkDBname"),".cdx")>0 or InStr(request("backpath"),".asp")>0 or InStr(request("backpath"),".asa")>0 or InStr(request("backpath"),".cer")>0 or InStr(request("backpath"),".cdx")>0 then response.Redirect("Default.asp") end if

if Action="Backup" or Action="BackupData" then
	call ShowBackup()
	set conn=nothing 
elseif Action="Compact" or Action="CompactData" then
	call ShowCompact()
	set conn=nothing 
elseif Action="Restore" or Action="RestoreData" then
	call ShowRestore()
	set conn=nothing 
elseif Action="SpaceSize" then
	call SpaceSize()
	set conn=nothing 
else
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
	set conn=nothing 
end if
if FoundErr=True then
	call WriteErrMsg()
end if

'--------备份数据库--------
sub ShowBackup()
%>
<table cellpadding="2" cellspacing="1" border="0" width="600" align="center" class="a2">
<form method="post" action="Database.asp?action=BackupData">
  <tr>
	<td colspan="3" align="center" height="25" class="a1"><FONT COLOR="#CC0000"><b>备 份 数 据 库</b></FONT></td>
  </tr>
<%    
if request("action")="BackupData" then
	call backupdata()
else
%>
          <tr class="a4"> 
            <td width="80" height="40" align="right">当前数据库:</td>
            <td><input name="db" type="text" size="40" value="<%=db%>"></td>
            <td>相对路径目录</td>
          </tr>
          <tr class="a4"> 
            <td width="80" height="40" align="right">备份目录:</td>
            <td><input type=text size=40 name=bkfolder value="Databackup"></td>
            <td>相对路径目录,如目录不存在,将自动创建</td>
          </tr>
          <tr class="a4"> 
            <td width="80" height="40" align="right">备份名称:</td>
            <td height="40"><input type=text size=40 name=bkDBname value="DataBack"></td>
            <td height="40">不用输入文件名后缀(默认为“.mdb”)。如有同名文件,将覆盖</td>
          </tr>
          <tr class="a4"> 
            <td height="40" colspan="3" align="center"><input name="submit" type=submit value=" &nbsp;开始备份&nbsp; " <%If ObjInstalled=false Then response.Write "disabled"%> style="cursor: hand;background-color: #cccccc;"></td>
          </tr>
<%
	If ObjInstalled=false Then
		Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
	end if
end if
%>
</form>
</table>
<%
end sub

'--------恢复数据库--------
sub ShowRestore()
%>
<table cellpadding="2" cellspacing="1" border="0" width="600" align="center" class="a2">
<form method="post" action="Database.asp?action=RestoreData">
  <tr>
	<td colspan="2" align="center" height="25" class="a1"><FONT COLOR="#CC0000"><b>数 据 库 恢 复</b></FONT></td>
  </tr>
<%
if request("action")="RestoreData" then
	call RestoreData()
else
%>
	<tr class="a4">
		<td width="150" height="40" align="right">备份数据库路径(相对):</td>
		<td height="40"><input name=backpath type=text id="backpath" value="Databackup/DataBack.mdb" size=50 maxlength="200"></td>
	</tr>
	<tr class="a4">
		<td width="150" height="40" align="right">当前数据库路径(相对):</td>
		<td><input name="db" type="text" size="50" maxlength="200" value="<%=db%>"></td>
	</tr>
	<tr align="center" class="a4"> 
		<td colspan="2"><input name="submit" type=submit value=" &nbsp;恢复数据&nbsp; " <%If ObjInstalled=false Then Response.Write "disabled"%> style="cursor: hand;background-color: #cccccc;"></td>
	</tr>
<%
	If ObjInstalled=false Then
		Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
	end if
end if
%>
            
</form>
</table>
<%
end sub

'--------压缩数据库--------
sub ShowCompact()
%>
<table cellpadding="2" cellspacing="1" border="0" width="600" align="center" class="a2">
<form method="post" action="Database.asp?action=CompactData">
  <tr align="center">
	<td class="a1" height="25"><FONT COLOR="#CC0000"><b>数 据 库 在 线 压 缩</b></FONT></td>
	</tr>
<%    
if request("action")="CompactData" then
	call CompactData()
else
%>
	<tr align="left" class="a4">
		<td valign="middle" style="line-height: 150%"><br><font color="#FF6600"><b>注1:</b></font>压缩前,建议先备份数据库,以免发生意外错误。 <br>
		<font color="#FF6600"><b>注2:</b></font>正在使用中数据库不能压缩,请选择备份数据库进行压缩操作(当前压缩数据库名为默认备份文件名)</td>
	</tr>
	<tr  align="left" class="a4">
		<td height="40">数据库位置: <input name="db" type="text" id="db" size="50" value="Databackup/DataBack.mdb"></td>
	</tr>
	<tr align="center" class="a4">
		<td height="40"><input name="submit" type=submit value=" &nbsp;压缩数据库&nbsp; " <%If ObjInstalled=false Then Response.Write "disabled"%> style="cursor: hand;background-color: #cccccc;"></td>
	</tr>
<%
	If ObjInstalled=false Then
		Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
	end if
end if
%>
</form>
</table>
<%
end sub

'--------统空间占用情况--------
sub SpaceSize()
	on error resume next
%>
<table cellpadding="2" cellspacing="1" border="0" width="600" align="center" class="a2">
  <tr>
	<td colspan="2" align="center" height="25" class="a1"><FONT COLOR="#CC0000"><b>系 统 空 间 占 用 情 况</b></FONT></td>
	</tr>
  <tr class="a4"> 
    <td width="100%" height="150" valign="middle">
	<blockquote><br>
      系统数据占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawbar("../database")%> height=10>&nbsp;
      <%showSpaceinfo("../database")%>
      <br>
      <br>
      备份数据占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawbar("databackup")%> height=10>&nbsp;
      <%showSpaceinfo("databackup")%>
      <br>
      <br>
      程序文件占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawspecialbar%> height=10>&nbsp;
      <%showSpecialSpaceinfo("Program")%>
      <br>
      <br>
      配色模板占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawbar("../Skin")%> height=10>&nbsp;
      <%showSpaceinfo("../Images")%>
      <br>
      <br>
      系统图片占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawbar("../Img")%> height=10>&nbsp;
      <%showSpaceinfo("../Img")%>
      <br>
      <br>
      上传文件占用空间:&nbsp;<img src="images/bar.gif" width=<%=drawbar("../UploadFiles")%> height=10>&nbsp;
      <%showSpaceinfo("../UploadFiles")%>
      <br>
      <br>
      系统占用空间总计:<BR><BR><img src="images/bar.gif" width=400 height=10> 
      <%showspecialspaceinfo("All")%>
	</blockquote> 	
    </td>
  </tr>
</table>
<%
end sub
%>
<BR>
<%htmlend%>

<%
'--------备份数据库--------
sub BackupData()
	dim bkfolder,bkdbname,fso
	db=trim(request.form("db"))
	bkfolder=trim(request("bkfolder"))
	bkdbname=trim(request("bkdbname"))
	if db="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定当数据库位置!</li>"

⌨️ 快捷键说明

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