我想把我的数据库备份到服务器上!
我的源码是这样的:<%@language=vbscript codepage=936 %>
<%
if session("admin")="" then
response.end
end if
%>
<!--#include file="conn.asp"-->
<%
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
Function CheckDir(FolderPath)
dim fso1
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
'存在
CheckDir = True
Else
'不存在
CheckDir = False
End if
Set fso1 = nothing
End Function'-------------根据指定名称生成目录---------
Function MakeNewsDir(foldername)
dim fso1,f
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
if request("action")="Backup" then
bkdbname=Request.Form("bkdbname")
If CheckDir(bkfolder) = True Then
dbpath=bkfolder
else
MakeNewsDir bkfolder
dbpath=bkfolder end if
sql="backup database ht to disk='"+dbpath+"\"&cstr(bkDBname)&".asa' "
On Error Resume Next
conn.Execute sql
call logfile(session("admin"),"成功备份数据库")
if err.number<>0 then
resu="数据库备份失败!"
else
resu="数据库成功备份为:"&cstr(bkdbname)
end if
end if
%>
<html>
<head>
<title>数据库备份</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form method="post" action="DataBackup.asp?action=Backup">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr class="title">
<td align="center" height="25" valign="middle"><b>数据库备份</b></td>
</tr>
<tr class="tdbg">
<td height="150" align="center" valign="middle"> <table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<td width="80" height="33" align="right">备份目录:</td>
<td><input type=text size=20 name=bkfolder value=Databackup></td>
<td>相对路径目录,如目录不存在,将自动创建</td>
</tr>
<tr>
<td width="80" height="34" align="right">备份名称:</td>
<td height="34"><input type=text size=20 name=bkDBname value="<%=date()%>"></td>
<td height="34">不用输入文件名后缀(默认为“.asa”)。如有同名文件,将覆盖</td>
</tr>
<tr align="center">
<td height="40" colspan="3"><input name="submit" type=submit value=" 开始备份 " ></td>
</tr>
</table>
<script language="vbscript"><%if resu<>"" then%>
window.alert "<%=resu%>"
<%end if%>
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
可总是备份失败!
我的源码是这样的:<%@language=vbscript codepage=936 %>
<%
if session("admin")="" then
response.end
end if
%>
<!--#include file="conn.asp"-->
<%
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
Function CheckDir(FolderPath)
dim fso1
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
'存在
CheckDir = True
Else
'不存在
CheckDir = False
End if
Set fso1 = nothing
End Function'-------------根据指定名称生成目录---------
Function MakeNewsDir(foldername)
dim fso1,f
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
if request("action")="Backup" then
bkdbname=Request.Form("bkdbname")
If CheckDir(bkfolder) = True Then
dbpath=bkfolder
else
MakeNewsDir bkfolder
dbpath=bkfolder end if
sql="backup database ht to disk='"+dbpath+"\"&cstr(bkDBname)&".asa' "
On Error Resume Next
conn.Execute sql
call logfile(session("admin"),"成功备份数据库")
if err.number<>0 then
resu="数据库备份失败!"
else
resu="数据库成功备份为:"&cstr(bkdbname)
end if
end if
%>
<html>
<head>
<title>数据库备份</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form method="post" action="DataBackup.asp?action=Backup">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr class="title">
<td align="center" height="25" valign="middle"><b>数据库备份</b></td>
</tr>
<tr class="tdbg">
<td height="150" align="center" valign="middle"> <table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<td width="80" height="33" align="right">备份目录:</td>
<td><input type=text size=20 name=bkfolder value=Databackup></td>
<td>相对路径目录,如目录不存在,将自动创建</td>
</tr>
<tr>
<td width="80" height="34" align="right">备份名称:</td>
<td height="34"><input type=text size=20 name=bkDBname value="<%=date()%>"></td>
<td height="34">不用输入文件名后缀(默认为“.asa”)。如有同名文件,将覆盖</td>
</tr>
<tr align="center">
<td height="40" colspan="3"><input name="submit" type=submit value=" 开始备份 " ></td>
</tr>
</table>
<script language="vbscript"><%if resu<>"" then%>
window.alert "<%=resu%>"
<%end if%>
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
可总是备份失败!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货