互联网与搜索引擎

:: ©技术专题:: ©互联网:: ©:电子商务: ©局域网搜索引擎研究与开发::

ASP备份Sql Server数据库

<% http://www.acnow.net/ xxcoA1lfx
Dim objSQLServer http://www.acnow.net/ xxcoA1lfx
Dim objBackup http://www.acnow.net/ xxcoA1lfx
Set objSQLServer = Server.CreateObject("SQLDMO.SQLServer") http://www.acnow.net/ xxcoA1lfx
objSQLServer.Connect "Localhost", "sa", "sa" http://www.acnow.net/ xxcoA1lfx
Set objBackup = Server.CreateObject("SQLDMO.Backup") http://www.acnow.net/ xxcoA1lfx
objBackup.Database = "vehicle" http://www.acnow.net/ xxcoA1lfx
objBackup.Files="d:/vehicle.bak" http://www.acnow.net/ xxcoA1lfx
objBackup.MediaDescription = "Back of vehicle" http://www.acnow.net/ xxcoA1lfx
On Error Resume Next http://www.acnow.net/ xxcoA1lfx
objBackup.SQLBackup(objSQLServer) http://www.acnow.net/ xxcoA1lfx
if Err<>0 then http://www.acnow.net/ xxcoA1lfx
strErr = Err.Description http://www.acnow.net/ xxcoA1lfx
response.write strErr http://www.acnow.net/ xxcoA1lfx
else http://www.acnow.net/ xxcoA1lfx
response.write "&Ecirc;&yacute;&frac34;&Yacute;&sup3;&Eacute;&sup1;&brvbar;±&cedil;·&Yacute;!" http://www.acnow.net/ xxcoA1lfx
end if http://www.acnow.net/ xxcoA1lfx
%>

http://www.acnow.net/ B7W6bI

2. http://www.acnow.net/ xxcoA1lfx
文件1:BackupDB.asp

<%@ Language=VBscript %> http://www.acnow.net/ xxcoA1lfx
<HTML> http://www.acnow.net/ xxcoA1lfx
<HEAD> http://www.acnow.net/ xxcoA1lfx
<meta name=VI60_defaultClientscript content=VBscript> http://www.acnow.net/ xxcoA1lfx
<meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0"> http://www.acnow.net/ xxcoA1lfx
<script ID=clientEventHandlersVBS LANGUAGE=vbscript> http://www.acnow.net/ xxcoA1lfx
<!--btnbak_onclick http://www.acnow.net/ xxcoA1lfx
if frmbak.txtsvr.value="" then http://www.acnow.net/ xxcoA1lfx
window.alert("'Server Name' is empty!") http://www.acnow.net/ xxcoA1lfx
frmbak.txtsvr.focus http://www.acnow.net/ xxcoA1lfx
exit sub http://www.acnow.net/ xxcoA1lfx
end if http://www.acnow.net/ xxcoA1lfx
if frmbak.txtuid.value="" then http://www.acnow.net/ xxcoA1lfx
window.alert("'Administrators' is empty!") http://www.acnow.net/ xxcoA1lfx
frmbak.txtuid.focus http://www.acnow.net/ xxcoA1lfx
exit sub http://www.acnow.net/ xxcoA1lfx
end if http://www.acnow.net/ xxcoA1lfx
if frmbak.txtdb.value="" then http://www.acnow.net/ xxcoA1lfx
window.alert("'Database' is empty!") http://www.acnow.net/ xxcoA1lfx
frmbak.txtdb.focus http://www.acnow.net/ xxcoA1lfx
exit sub http://www.acnow.net/ xxcoA1lfx
end if http://www.acnow.net/ xxcoA1lfx
if frmbak.txtto.value="" then http://www.acnow.net/ xxcoA1lfx
window.alert("'Backup To' is empty!") http://www.acnow.net/ xxcoA1lfx
frmbak.txtto.focus http://www.acnow.net/ xxcoA1lfx
exit sub http://www.acnow.net/ xxcoA1lfx
end if http://www.acnow.net/ xxcoA1lfx
frmbak.submit http://www.acnow.net/ xxcoA1lfx
End Sub--> http://www.acnow.net/ xxcoA1lfx
</script> http://www.acnow.net/ xxcoA1lfx
<link rel="stylesheet" href="../../sheets/B2BStyle.css"> http://www.acnow.net/ xxcoA1lfx
</HEAD> http://www.acnow.net/ xxcoA1lfx
<form action="backupdbsave.asp" method="post" id=frmbak name=frmbak> http://www.acnow.net/ xxcoA1lfx
<body class="bg_frame_up"> http://www.acnow.net/ xxcoA1lfx
<p class=heading> Database --> Backup</p> http://www.acnow.net/ xxcoA1lfx
<P align=center> http://www.acnow.net/ xxcoA1lfx
<div align="center"> http://www.acnow.net/ xxcoA1lfx
<center> http://www.acnow.net/ xxcoA1lfx
<table width="60%" cellpadding=1 cellspacing=1 border=0 align=center> http://www.acnow.net/ xxcoA1lfx
<tr> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_FN align="center" height="35" width="40%">Server Name:</td> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_F height="35" width="59%"> http://www.acnow.net/ xxcoA1lfx
<INPUT id=txtsvr name=txtsvr size="20" style="font-family: Arial; font-size: 9pt"></td> http://www.acnow.net/ xxcoA1lfx
</tr> http://www.acnow.net/ xxcoA1lfx
<tr> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_FN align="center" height="35" width="40%">Administrators:</td> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_F height="35" width="59%"> http://www.acnow.net/ xxcoA1lfx
<INPUT id=txtuid name=txtuid size="20" style="font-family: Arial; font-size: 9pt"></td> http://www.acnow.net/ xxcoA1lfx
</tr> http://www.acnow.net/ xxcoA1lfx
<tr> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_FN align="center" height="35" width="40%">Password:</td> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_F height="35" width="59%"> http://www.acnow.net/ xxcoA1lfx
<INPUT id=txtpwd name=txtpwd type=password style="font-family: Arial; font-size: 9pt"></td> http://www.acnow.net/ xxcoA1lfx
</tr> http://www.acnow.net/ xxcoA1lfx
<tr> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_FN align="center" height="35" width="40%">Database:</td> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_F height="35" width="59%"> http://www.acnow.net/ xxcoA1lfx
<p align="left"> http://www.acnow.net/ xxcoA1lfx
<INPUT id=txtdb name=txtdb size="20" style="font-family: Arial; font-size: 9pt"></p> http://www.acnow.net/ xxcoA1lfx
</td> http://www.acnow.net/ xxcoA1lfx
</tr>http://www.acnow.net/ xxcoA1lfx

<td class=TD_Mand_FN align="center" height="35" width="40%">Backup T<br/> http://www.acnow.net/ xxcoA1lfx
<u>(Server Path)</u></td> http://www.acnow.net/ xxcoA1lfx
<td class=TD_Mand_F height="35" width="59%"> http://www.acnow.net/ xxcoA1lfx
<input id=txtto name=txtto style="font-family: Arial; font-size: 9pt"></td> http://www.acnow.net/ xxcoA1lfx
</tr> http://www.acnow.net/ xxcoA1lfx
</table> http://www.acnow.net/ xxcoA1lfx
</center> </div> http://www.acnow.net/ xxcoA1lfx
<p align=center><input id=btnbak name=btnbak type=button value="Start Backup" style="font-family: Arial; font-size: 9pt"></p> http://www.acnow.net/ xxcoA1lfx
</body> http://www.acnow.net/ xxcoA1lfx
</form> http://www.acnow.net/ xxcoA1lfx
</HTML>

http://www.acnow.net/ xxcoA1lfx

http://www.acnow.net/ xxcoA1lfx
文件2:BackupDBSave.asp

http://www.acnow.net/ xxcoA1lfx

<%@ Language=VBscript %> http://www.acnow.net/ xxcoA1lfx
<% http://www.acnow.net/ xxcoA1lfx
dim msvr,muid,mpwd,mdb,mto http://www.acnow.net/ xxcoA1lfx
msvr=Request.Form("txtsvr") http://www.acnow.net/ xxcoA1lfx
muid=Request.Form("txtuid") http://www.acnow.net/ xxcoA1lfx
mpwd=Request.Form("txtpwd") http://www.acnow.net/ xxcoA1lfx
mdb=Request.Form("txtdb") http://www.acnow.net/ xxcoA1lfx
mto=Request.Form("txtto") http://www.acnow.net/ xxcoA1lfx
if mpwd="" then mpwd="''"

http://www.acnow.net/ xxcoA1lfx

on error resume next http://www.acnow.net/ xxcoA1lfx
set dmosvr=server.CreateObject("SQLDMO.SQLServer") http://www.acnow.net/ xxcoA1lfx
dmosvr.connect msvr,muid,mpwd

http://www.acnow.net/ xxcoA1lfx

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

http://www.acnow.net/ xxcoA1lfx

mdevname="Backup_"&muid&"_"&mdb http://www.acnow.net/ xxcoA1lfx
set dmodev=server.CreateObject("SQLDMO.BackupDevice") http://www.acnow.net/ xxcoA1lfx
dmodev.name=mdevname http://www.acnow.net/ xxcoA1lfx
dmodev.type=2 http://www.acnow.net/ xxcoA1lfx
dmodev.PhysicalLocation=mto http://www.acnow.net/ xxcoA1lfx
dmosvr.BackupDevices.Add dmodev

http://www.acnow.net/ xxcoA1lfx

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

http://www.acnow.net/ xxcoA1lfx

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

http://www.acnow.net/ xxcoA1lfx

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

http://www.acnow.net/ xxcoA1lfx

dmosvr.backupdevices(mdevname).remove http://www.acnow.net/ xxcoA1lfx
set dmobak=nothing http://www.acnow.net/ xxcoA1lfx
set dmodev=nothing http://www.acnow.net/ xxcoA1lfx
dmosvr.disconnect http://www.acnow.net/ xxcoA1lfx
set dmosvr=nothing http://www.acnow.net/ xxcoA1lfx
%> http://www.acnow.net/ xxcoA1lfx
<p><strong>Database '<%=mdb%>' backup successed!</strong></p> http://www.acnow.net/ xxcoA1lfx
</BODY> http://www.acnow.net/ xxcoA1lfx
</HTML>

http://www.acnow.net/ xxcoA1lfx

http://www.acnow.net/ xxcoA1lfx
文件3:BackupErr.asp

http://www.acnow.net/ xxcoA1lfx

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

btnret_onclick http://www.acnow.net/ xxcoA1lfx
history.back http://www.acnow.net/ xxcoA1lfx
End Sub

--> http://www.acnow.net/ xxcoA1lfx
</script> http://www.acnow.net/ xxcoA1lfx
<title></title> http://www.acnow.net/ xxcoA1lfx
</HEAD> http://www.acnow.net/ xxcoA1lfx
<body class="bg_frame_up"> http://www.acnow.net/ xxcoA1lfx
<p align=center><font color=#006666><%=errstr%></font></p> http://www.acnow.net/ xxcoA1lfx
<p align=center><input id=btnret name=btnret type=button value=Return style="font-family: Arial; font-size: 9pt"></p> http://www.acnow.net/ xxcoA1lfx
</BODY> http://www.acnow.net/ xxcoA1lfx
</HTML>

阅读更多
个人分类: System/Database
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

ASP备份Sql Server数据库

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭