asp备份恢复ACCESS数据库代码示例

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="UTF-8" />

<!--#include file="../web_inc/conn.asp"-->
<!--#include file="../web_inc/function.asp"-->
<!--#include file="../web_inc/stonefunction.asp"-->
<!--#include file="chkadmin.asp"-->

<%
pagetitle="数据库管理"
dbpath="../web_date/#Stone.mdb"

action=request.QueryString("action")
select case action
case "bak"
    fpath=request.form("fpath")
    fpath=server.mappath(fpath)
    tpath=request.form("tpath")
    tpath=server.mappath(tpath)
    bakname=request.form("bakname")
    'On error resume next
    Set objfso = Server.CreateObject("Scripting.FileSystemObject")
    if err then
    err.clear
    response.write "<script>alert(""不能建立fso对象,请确保你的空间支持fso:!"");history.back();</script>"
    response.end
    end if
    
    if objfso.Folderexists(tpath) = false then
    Set fy=objfso.CreateFolder(tpath)
    end if
    
    objfso.copyfile fpath,tpath& "\"& bakname
    call gotourlmsg("备份数据库成功!","data_command.asp",0)
case "reset"
    fpath=request.form("fpath")
    fpath=server.mappath(fpath)
    tpath=request.form("tpath")
    if tpath="" then
    response.write "<script>alert(""请输入您要恢复的数据库路径及全名"");history.back();</script>"
    else
    tpath=server.mappath(tpath)
    end if
    'on error resume next
    Set objfso = Server.CreateObject("Scripting.FileSystemObject")
    if err then
    err.clear
    response.write "<script>alert(""不能建立fso对象,请确保你的空间支持fso:!"");history.back();</script>"
    response.end
    end if
    if objfso.fileexists(tpath) then
    objfso.copyfile ""&tpath&"",""&fpath&""
    
    else
    response.write "<script>alert(""错误:备份目录下无您的备份文件!"");history.back();</script>"
    response.end
    end if
    call gotourlmsg("数据库恢复成功!","data_command.asp",0)
end select
%>

<meta name="robots" content="all" />
<meta name="author" content="<%=WebName%>" />
<meta name="Copyright" content="<%=WebName%>" />
<meta name="keywords" content="<%=Webkeywords%>" />
<meta name="description" content="<%=Webdescription%>" />
<title><%=WebName%> - 东方之子后台管理系统 V1.0</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/main.css" type="text/css" media="all" />
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>

<body>

<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:10px;">
  <tr>
    <td><table width="780" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="24"><img src="images/localGIF.gif" width="17" height="17" /></td>
        <td width="756" valign="bottom">管理首页 >> <%=pagetitle%></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    
    <table width="780" border="0" cellspacing="0" cellpadding="0" class="tab1" >
      <tr>
        <td><form id="form1" name="form1" method="post" action="data_command.asp?action=bak">
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="tab2">
            <tr>
              <td class="td1">数据库备份</td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0">
                  <tr>
                    <td width="24%" class="td2">源数据库路径:</td>
                    <td width="76%" class="td3"><input name="fpath" type="text" id="fpath" value="<%=dbpath%>" size="70" readonly/></td>
                  </tr>
                  <tr>
                    <td class="td2">数据库备份目录:</td>
                    <td class="td3"><input name="tpath" type="text" id="tpath" value="../date_bak" size="70" readonly /></td>
                  </tr>
                  <tr>
                    <td class="td2">数据库备份名称:</td>
                    <td class="td3"><input name="bakname" type="text" id="bakname" value="date_bak.mdb" size="70" readonly /></td>
                  </tr>


              </table>
                <br />
                
                <input name="Submit" type="submit" class="btn" value="备 份" /></td>
            </tr>
          </table>
                </form>
          <br />
          <form id="form1" name="form1" method="post" action="data_command.asp?action=reset">
            <table width="100%" border="0" cellpadding="0" cellspacing="1" class="tab2">
              <tr>
                <td class="td1">数据库恢复</td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="1" cellpadding="0">
                    <tr>
                      <td width="24%" class="td2">当前数据库路径:</td>
                      <td width="76%" class="td3"><input name="fpath" type="text" id="fpath" value="<%=dbpath%>" size="70" readonly /></td>
                    </tr>
                    <tr>
                      <td class="td2">备份数据库的路径:</td>
                      <td class="td3"><input name="tpath" type="text" id="tpath" value="../date_bak/date_bak.mdb" size="70"  readonly/></td>
                    </tr>

                </table>
                  <br />
                  <input name="Submit2" type="submit" class="btn" value="恢 复" />
                  <br /><br /></td>
              </tr>
            </table>
          </form></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
  <tr>
    <td><span class="STYLE1">该功能要求空间支持FSO</span></td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
</body>
</html>
<%
conn.close
set conn=nothing
%>



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 1 | 引用: 0 | 查看次数: 943
  • 1
admin [2009-10-26 02:41 PM]
ddd
  • 1
发表评论
昵 称:
密 码: 游客发言不需要密码.
验证码: 验证码
内 容:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 关闭 | [img]标签 关闭