我用ASP备份sqlserver 一个程序以前用的可以,现在每次都提示备份地址出错

csteven 2003-11-25 09:50:50
但实际上我没有更改任何地址!
...全文
56 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
baby21st 2003-11-25
  • 打赏
  • 举报
回复
检查程序是否和当前的地址相配

肯定有问题
肯定能找出问题
肯定能解决问题

lovehwq21 2003-11-25
  • 打赏
  • 举报
回复
错误很明显,你备份的路径错了
qxs 2003-11-25
  • 打赏
  • 举报
回复
我给你个程序

<%

dim strDataBaseName,strUserName,strPwd,strServerName,strFoldName

strDataBaseName=trim(request("strDataBaseName"))
strUserName=trim(request("strUserName"))
strPwd=trim(request("strPwd"))
strServerName=trim(request("strServerName"))
strFoldName=trim(request("strFoldName"))

pCommand=trim(request("pCommand"))

if pCommand<>"" then
call BackupSqlDataBase(strDataBaseName,strUserName,strPwd,strServerName,strFoldName)
end if

function BackupSqlDataBase(strDataBaseName,strUserName,strPwd,strServerName,strFoldName)
dim dbconn
dim strConn

if strUserName="" then
strUserName="sa"
end if
if strServerName="" then
strServerName="(Local)"
end if

if strDataBaseName<>"" then
on error resume next
strConn="Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=" & strDataBaseName & ";Data Source=" & strServerName
strUid=strUserName
strPwd=strPwd

Set dbconn=Server.CreateObject("ADODB.CONNECTION")
dbconn.Open strConn,strUid,strPwd


if err.number<>0 then
Response.Write "<center>"
Response.Write "<font style='color:red;font-size:9pt'>"
Response.Write "请重新输入要备份数据库的信息!"
Response.Write "</font>"
Response.Write "</center>"
else
if strFoldName="" then
strFoldName="DataBackup"
end if

set objFs=server.CreateObject("scripting.FileSystemObject")
CurryFoldName=server.MapPath(".") & "\" & strFoldName

if objFs.FolderExists(CurryFoldName)=false then
objFs.CreateFolder CurryFoldName
end if

DataBaseName=strDataBaseName & year(date()) & month(date()) & day(date())
DataPathFileName=CurryFoldName & "\" & DataBaseName

if objFs.FolderExists(DataPathFileName & ".bak")=true then
objFs.DeleteFile DataPathFileName & ".bak"
end if

strSql="BACKUP DATABASE " & strDataBaseName & " TO disk='" & DataPathFileName & ".bak' with init "
dbconn.execute strSql

set dbconn=nothing

if err.number<>0 then
strMsg="数据库与WEB服务器不在同一台服务器,备份失败!"
if objFs.FolderExists(CurryFoldName)=true then
objFs.DeleteFolder CurryFoldName
end if
else
strMsg="恭喜您数据库备份成功!<font color=""red"">(路径:" & DataPathFileName & ".bak" & ")</font>"
end if
set objFs=nothing
Response.Write "<center style=""font-size:9pt"">"
Response.Write strMsg
Response.Write "</center>" & vbcrlf

end if
else
Response.Write "<center>"
Response.Write "<font style='color:red;font-size:9pt'>"
Response.Write "请重新输入要备份数据库的信息!"
Response.Write "</font>"
Response.Write "</center>"
end if
end function



%>
<html>
<head>
<title>SQL数据库备份</title>
</head>
<body>
<center>
<form action="" method="post" name="HdForm">
<table width="439" border="0" style="BORDER-BOTTOM: deepskyblue 1px solid; BORDER-LEFT: deepskyblue 1px solid; BORDER-RIGHT: deepskyblue 1px solid; BORDER-TOP: deepskyblue 1px solid; FONT-SIZE: 9pt; HEIGHT: 154px; WIDTH:400px" cellPadding=0 cellSpacing=1>
<tr>

<td bgColor=lavenderblush align="right" width="138">数据库名:</td>

<td width="259">
<input name="strDataBaseName" style="BORDER-BOTTOM: orange 1px solid; BORDER-LEFT: orange 1px solid; BORDER-RIGHT: orange 1px solid; BORDER-TOP: orange 1px solid; HEIGHT: 20px; WIDTH: 210px" ></td>
</tr>
<tr>

<td bgColor=lavenderblush align="right" width="138">数据库登录名:</td>

<td width="259">
<input name="strUserName" style="BORDER-BOTTOM: orange 1px solid; BORDER-LEFT: orange 1px solid; BORDER-RIGHT: orange 1px solid; BORDER-TOP: orange 1px solid; HEIGHT: 20px; WIDTH: 210px" value="sa"></td>
</tr>
<tr>

<td bgColor=lavenderblush align="right" width="138">数据库登录密码:</td>

<td width="259">
<input name="strPwd" style="BORDER-BOTTOM: orange 1px solid; BORDER-LEFT: orange 1px solid; BORDER-RIGHT: orange 1px solid; BORDER-TOP: orange 1px solid; HEIGHT: 20px; WIDTH: 210px" type="password"></td>
</tr>
<tr>

<td bgColor=lavenderblush align="right" width="138">服务器名:</td>

<td width="259">
<input name="strServerName" style="BORDER-BOTTOM: orange 1px solid; BORDER-LEFT: orange 1px solid; BORDER-RIGHT: orange 1px solid; BORDER-TOP: orange 1px solid; HEIGHT: 20px; WIDTH: 210px" value="."></td>
</tr>
<tr>

<td bgColor=lavenderblush align="right" width="138">保存文件夹名:</td>

<td width="259">
<input name="strFoldName" style="BORDER-BOTTOM: orange 1px solid; BORDER-LEFT: orange 1px solid; BORDER-RIGHT: orange 1px solid; BORDER-TOP: orange 1px solid; HEIGHT: 20px; WIDTH: 210px" value="DataBackup" size="20">

</td>
</tr>
</table>

<table width="100%">
<tr>
<td align="center">
<input type="button" value="备份" name="button1" style="BACKGROUND-COLOR: whitesmoke; BORDER-BOTTOM: lightgrey 1px solid; BORDER-LEFT: lightgrey 1px solid;WIDTH: 69px" onclick="pSumbit()">
<input type="reset" value="取消" name="button2" style="BACKGROUND-COLOR: whitesmoke; BORDER-BOTTOM: lightgrey 1px solid; BORDER-LEFT: lightgrey 1px solid;WIDTH: 69px">
<input type="hidden" value="" name="pCommand">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<script language="vbscript">
<!--
function pSumbit()
if trim(HdForm.strDataBaseName.value)="" then
alert("请输入要备份的数据库名!")
HdForm.strDataBaseName.focus()
exit function
end if
HdForm.pCommand.value="strBackup"
HdForm.submit()
end function
-->
</script>
xieyj 2003-11-25
  • 打赏
  • 举报
回复
判断是否有空间,还有权限问题。
vivisogood 2003-11-25
  • 打赏
  • 举报
回复
应该是sqlserver本身的问题或者系统的问题!还有可能是权限变了!
csteven 2003-11-25
  • 打赏
  • 举报
回复
我把sqlserver的agent 重新安装后解决了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧