分享
 
 
 

用ASP备份数据库

王朝asp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

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

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

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有