将用asp写的备份数据库的五个文件代码粘出来。但请教的是我无论怎么样在BackUpDB.asp中填写用户名和密码,都提示错误!

CheerYang 2004-05-02 02:41:19
将用asp写的备份数据库的五个文件代码粘出来。但请教的是我无论怎么样在BackUpDB.asp中填写用户名和密码,都提示错误!

以下是代码区

'****************
' 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> 数据库 --> 备份</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%">服务器名字:</td>
<td class=TD_Mand_F height="35" width="59%"> 
<INPUT id=txtsvr name=txtsvr size="20" style="font-family: Arial; font-size: 9pt" value="showfray"></td>
</tr>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">用户名:</td>
<td class=TD_Mand_F height="35" width="59%"> 
<INPUT id=txtuid name=txtuid size="20" style="font-family: Arial; font-size: 9pt" value="sa"></td>
</tr>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">口令:</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%">数据库名:</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" value="zhoa"></p>
</td>
</tr>

<td class=TD_Mand_FN align="center" height="35" width="40%">备份到:<br>
<u>(服务器路径)</u></td>
<td class=TD_Mand_F height="35" width="59%"> 
<input id=txtto name=txtto style="font-family: Arial; font-size: 9pt" value="c:\" size="59"></td>
</tr>
</table>
</center> </div>
<p align=center><input id=btnbak name=btnbak type=button value="开始备份" style="font-family: Arial; font-size: 9pt"></p>
</body>
</form>
</HTML>


'*************
' 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>正在备份,请稍候.....</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>数据库 ''<%=mdb%>'' 备份成功!</strong></p>
</BODY>
</HTML>


'*****************
' BackupErr.asp 备份数据出错提示页面
'******************
<%@ Language=VBScript %>
<%
dim errno,errstr
errno=Request.QueryString("err")
errstr=""
select case cstr(errno)
case "18456"
errstr="管理员用户名或密码错误!"
case "20482"
errstr="服务器名字错误或服务器不能连接!"
case "911"
errstr="该数据库不存在!"
case "15026"
errstr="服务器路径找不到!"
case "3201"
errstr="服务器路径找不到!"
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>


'下续

...全文
29 4 点赞 打赏 收藏 举报
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
sfar 2004-07-05
在页面上面加上错误处理,在页面前面加上on error resume next,
打印错误:response.write Err.Description
  • 打赏
  • 举报
回复
huhanshan013 2004-07-05
我页这样做了一下
提示是:
errstr="unknown error! retry later please!"

怎么办?
可能会是什么问题?
  • 打赏
  • 举报
回复
lang11zi 2004-05-02
你搞个别动网的论坛看一下就ok了
  • 打赏
  • 举报
回复
CheerYang 2004-05-02
'续上

'************
' 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>

'*************
' 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>正在恢复,请稍候...</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>数据库 ''<%=mdb%>'' 恢复成功!</strong></p>
</BODY>
</HTML>
  • 打赏
  • 举报
回复
相关推荐
发帖
ASP
加入

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-05-02 02:41
社区公告
暂无公告