当前位置: 首页 > 设计代码 > 正文

ASP备份数据库

文件1:BackupDB.asp
 

<%@ Language=VBScript %>




Database –> Backup

Server Name:
Administrators:
Password:
Database:

Backup To:
(Server Path)


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




Backuping, wait please…

<% 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
%>

Database '<%=mdb%>' backup successed!


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







<%=errstr%>


本文固定链接: http://blog.duoday.com/2006/150.html | 奇风's Blog

该日志由 于2006年08月02日发表在 设计代码 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。

原创文章转载请注明: ASP备份数据库 | 奇风's Blog

关键字:

ASP备份数据库:等您坐沙发呢!

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注
? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen
快捷键:Ctrl+Enter