论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > asp教程
Tag:入门,文摘,实例,技巧,iis,表单,对象,上传,数据库,记录集,session,cookies,存储过程,注入,分页,安全,优化,xmlhttp,fso,jmail,application,防盗链,stream,组件,md5,乱码,缓存,加密,验证码,算法,ubb,正则表达式,水印,,日志,压缩,url重写,控件,函数,破解,触发器,socket,ADO,初学,聊天室,留言本,视频教程

ASP数据库恢复的代码

文章类别:asp | 发表日期:2008-10-5 20:40:35

文件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>

文件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>


上一篇:{实例}限制只能中文输入的方法 人气:3903
下一篇:{实例}简单的浮点论坛 人气:4002
视频教程列表
文章教程搜索
 
Asp推荐教程
Asp热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058