class="area">
ASP實現備份和恢復SQL2000數據庫的代碼:
1、備份
<%
SQL="backup database 數據庫名 to disk=’"&Server.MapPath("backup")&"\"&"backuptext.dat"&"’"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.write "錯誤:"&err.Descripting
else
response.write "數據備份成功!"
end if
%>
2、恢復
<%
SQL="Restore database 數據庫名 from disk=’"&Server.MapPath("backup")&"\"&"backuptext.dat"&"’"
set cnn=Server.createobject("adodb.connection")
cnn.open "driver={SQL Server};Server=服務器名;uid=sa;pwd="
cnn.execute SQL
on error resume next
if err<>0 then
response.write "錯誤:"&err.Descripting
else
response.write "數據恢復成功!"
end if
%>