| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 531 人关注过本帖
标题:ligao521看看吧,asp备份数据库
取消只看楼主 加入收藏
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
 问题点数:0 回复次数:4 
ligao521看看吧,asp备份数据库
文件1:BackupDB.asp

<%@  Language=VBScript  %>
<HTML>
<HEAD>
<META  name=VI60_defaultClientScript  content=VBScript>
<META  NAME="GENERATOR"  Content="Microsoft  FrontPage  4.0">
<SCRIPT  ID=clientEventHandlersVBS  LANGUAGE=vbscript>
<!--

Sub  btnbak_onclick
        if  frmbak.txtsvr.value=""  then
                window.alert("''Server  Name''  is  empty!")
                frmbak.txtsvr.focus
                exit  sub
        end  if
        if  frmbak.txtuid.value=""  then
                window.alert("''Administrators''  is  empty!")
                frmbak.txtuid.focus
                exit  sub
        end  if
        if  frmbak.txtdb.value=""  then
                window.alert("''Database''  is  empty!")
                frmbak.txtdb.focus
                exit  sub
        end  if
        if  frmbak.txtto.value=""  then
                window.alert("''Backup  To''  is  empty!")
                frmbak.txtto.focus
                exit  sub
        end  if
        frmbak.submit
End  Sub

-->
</SCRIPT>
<link  rel="stylesheet"  href="../../sheets/B2BStyle.css">
</HEAD>
<form  action="backupdbsave.asp"  method="post"  id=frmbak  name=frmbak>
<body  class="bg_frame_up">
<p  class=heading> Database  -->  Backup</p>
<P  align=center>
<div  align="center">
    <center>
            <table  width="60%"  cellpadding=1  cellspacing=1  border=0  align=center>
                <tr>
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Server  Name:</td>
                    <td  class=TD_Mand_F  height="35"  width="59%">   
                        <INPUT  id=txtsvr  name=txtsvr  size="20"  style="font-family:  Arial;  font-size:  9pt"></td>
        </tr>
        <tr>
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Administrators:</td>
                    <td  class=TD_Mand_F  height="35"  width="59%">   
                        <INPUT  id=txtuid  name=txtuid  size="20"  style="font-family:  Arial;  font-size:  9pt"></td>
        </tr>
        <tr>
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Password:</td>
                    <td  class=TD_Mand_F  height="35"  width="59%">   
                        <INPUT  id=txtpwd  name=txtpwd  type=password  style="font-family:  Arial;  font-size:  9pt"></td>
        </tr>
        <tr>
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Database:</td>
                    <td  class=TD_Mand_F  height="35"  width="59%">  
                        <p  align="left"> 
                        <INPUT  id=txtdb  name=txtdb  size="20"  style="font-family:  Arial;  font-size:  9pt"></p>
        </td>
        </tr>
               
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Backup  T<br>
                        <u>(Server  Path)</u></td>   
                    <td  class=TD_Mand_F  height="35"  width="59%">   
                        <input  id=txtto  name=txtto  style="font-family:  Arial;  font-size:  9pt"></td>   
        </tr>   
</table>  
</center>  </div>   
<p  align=center><input  id=btnbak  name=btnbak  type=button  value="Start  Backup"  style="font-family:  Arial;  font-size:  9pt"></p>   
</body>   
</form>   
</HTML>   

[此贴子已经被作者于2005-7-6 18:33:50编辑过]


搜索更多相关主题的帖子: 数据库 asp 
2005-07-06 18:26
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
得分:0 
文件2:BackupDBSave.asp

<%@  Language=VBScript  %>
<%
dim  msvr,muid,mpwd,mdb,mto
msvr=Request.Form("txtsvr")
muid=Request.Form("txtuid")
mpwd=Request.Form("txtpwd")
mdb=Request.Form("txtdb")
mto=Request.Form("txtto")
if  mpwd=""  then  mpwd="''''"

on  error  resume  next
set  dmosvr=server.CreateObject("SQLDMO.SQLServer")
dmosvr.connect  msvr,muid,mpwd

if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

mdevname="Backup_"&muid&"_"&mdb
set  dmodev=server.CreateObject("SQLDMO.BackupDevice")
dmodev.name=mdevname
dmodev.type=2
dmodev.PhysicalLocation=mto
dmosvr.BackupDevices.Add  dmodev

if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

set  dmobak=server.CreateObject("SQLDMO.Backup")
dmobak.database=mdb
dmobak.devices=mdevname
%>
<HTML>
<HEAD>
<META  NAME="GENERATOR"  Content="Microsoft  Visual  Studio  6.0">
</HEAD>
<body  background="../../Images/dot.gif">

<p><strong>Backuping,  wait  please...</strong></p>
<%
dmobak.sqlbackup  dmosvr
if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

dmosvr.backupdevices(mdevname).remove
set  dmobak=nothing
set  dmodev=nothing
dmosvr.disconnect
set  dmosvr=nothing
%>
<p><strong>Database  ''<%=mdb%>''  backup  successed!</strong></p>
</BODY>
</HTML>
2005-07-06 18:28
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
得分:0 
文件3:BackupErr.asp

<%@  Language=VBScript  %>
<%
dim  errno,errstr
errno=Request.QueryString("err")
errstr=""
select  case  cstr(errno)
        case  "18456"
                errstr="administrators  or  password  error!"
        case  "20482"
                errstr="server  name  error  or  server  cannot  connect!"
        case  "911"
                errstr="database  not  found!"
        case  "15026"
                errstr="server  path  not  found!"
        case  "3201"
                errstr="server  path  not  found!"
        case  "3254"
                errstr="restore  from  file  lawlessness!"
        case  else
                errstr="unknown  error!  retry  later  please!"
end  select
%>
<HTML>
<HEAD>
<META  name=VI60_defaultClientScript  content=VBScript>
<META  NAME="GENERATOR"  Content="Microsoft  FrontPage  4.0">
<SCRIPT  ID=clientEventHandlersVBS  LANGUAGE=vbscript>
<!--

Sub  btnret_onclick
        history.back
End  Sub

-->
</SCRIPT>
<title></title>
</HEAD>
<body    class="bg_frame_up">
<p  align=center><font  color=#006666><%=errstr%></font></p>
<p  align=center><input  id=btnret  name=btnret  type=button  value=Return  style="font-family:  Arial;  font-size:  9pt"></p>
</BODY>
</HTML>
2005-07-06 18:29
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
得分:0 
文件4:RestoreDB.asp

<%@  Language=VBScript  %>
<HTML>
<HEAD>
<META  name=VI60_defaultClientScript  content=VBScript>
<META  NAME="GENERATOR"  Content="Microsoft  FrontPage  4.0">
<SCRIPT  ID=clientEventHandlersVBS  LANGUAGE=vbscript>
<!--

Sub  btnbak_onclick
        if  frmbak.txtsvr.value=""  then
                window.alert("''Server  Name''  is  empty!")
                frmbak.txtsvr.focus
                exit  sub
        end  if
        if  frmbak.txtuid.value=""  then
                window.alert("''Administrators''  is  empty!")
                frmbak.txtuid.focus
                exit  sub
        end  if
        if  frmbak.txtdb.value=""  then
                window.alert("''Database''  is  empty!")
                frmbak.txtdb.focus
                exit  sub
        end  if
        if  frmbak.txtto.value=""  then
                window.alert("''Restore  From''  is  empty!")
                frmbak.txtto.focus
                exit  sub
        end  if
        frmbak.submit
End  Sub

-->
</SCRIPT>
</HEAD>
<form  action="restoredbsave.asp"  method="post"  id=frmbak  name=frmbak>
<body  class="bg_frame_up">
<link  rel="stylesheet"  href="../../sheets/B2BStyle.css">

<p  class=heading> Database  -->  Restore</p>

<P  align=center>
<div  align="center">
    <center>
            <table  width="60%"  height="71"  cellpadding=1  cellspacing=1  border=0  align=center>
                <tr>
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Server  Name:</td>  
                    <td  class=TD_Mand_F  height="35"> 
<INPUT  id=txtsvr  name=txtsvr  size="20"  style="font-family:  Arial;  font-size:  9pt"></td>  
        </tr>  
        <tr>  
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Administrators:</td>  
                    <td  class=TD_Mand_F  height="35"> 
<INPUT  id=txtuid  name=txtuid  style="font-family:  Arial;  font-size:  9pt"></td>  
        </tr>  
        <tr>  
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Password:</td>  
                    <td  class=TD_Mand_F  height="35"> 
<INPUT  id=txtpwd  name=txtpwd  type=password  style="font-family:  Arial;  font-size:  9pt"></td>  
        </tr>  
        <tr>  
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Database:</td>  
                    <td  class=TD_Mand_F  height="35"> 
<INPUT  id=txtdb  name=txtdb  style="font-family:  Arial;  font-size:  9pt"></td>  
        </tr>  
        <tr>  
                    <td  class=TD_Mand_FN  align="center"  height="35"  width="40%">Restore  
                        From:<br>
                        <u>(Server  Path)</u></td>      
                    <td  class=TD_Mand_F  height="35"> 
<input  id=txtto  name=txtto  style="font-family:  Arial;  font-size:  9pt"></td>      
        </tr>      
</table></center>      
</div>      
<p  align=center><input  id=btnbak  name=btnbak  type=button  value="Start  Restore"  style="font-family:  Arial;  font-size:  9pt"></p>      
</body>      
</form>      
</HTML>
2005-07-06 18:30
downdown
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2005-6-20
收藏
得分:0 
文件5:RestoreDBSave.asp

<%@  Language=VBScript  %>
<%
dim  msvr,muid,mpwd,mdb,mto
msvr=Request.Form("txtsvr")
muid=Request.Form("txtuid")
mpwd=Request.Form("txtpwd")
mdb=Request.Form("txtdb")
mto=Request.Form("txtto")
if  mpwd=""  then  mpwd="''''"

on  error  resume  next
set  dmosvr=server.CreateObject("SQLDMO.SQLServer")
dmosvr.connect  msvr,muid,mpwd

if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

mdevname="Restore_"&muid&"_"&mdb
dmosvr.backupdevices(mdevname).remove
err.clear

set  dmodev=server.CreateObject("SQLDMO.BackupDevice")
dmodev.name=mdevname
dmodev.type=2
dmodev.PhysicalLocation=mto
dmosvr.BackupDevices.Add  dmodev

if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

set  dmores=server.CreateObject("SQLDMO.Restore")
dmores.database=mdb
dmores.devices=mdevname
%>
<HTML>
<HEAD>
<META  NAME="GENERATOR"  Content="Microsoft  Visual  Studio  6.0">
</HEAD>
<body    class="bg_frame_up">

<p><strong>Restoring,  wait  please...</strong></p>
<%
dmores.sqlrestore  dmosvr
if  err.number>0  then  Response.Redirect("http:backuperr.asp?err="&err.number)

set  dmores=nothing
set  dmodev=nothing
dmosvr.disconnect
set  dmosvr=nothing
%>
<p><strong>Database  ''<%=mdb%>''  restore  successed!</strong></p>
</BODY>
</HTML>
2005-07-06 18:31
快速回复:ligao521看看吧,asp备份数据库
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019379 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved