ASP实现SQL备份、恢复
发布时间:2016-12-29 来源:查字典编辑
摘要:1、备份绿色chinaipower.comAYrCJ6B2、恢复
1、备份
<%
SQL="backupdatabase数据库名todisk='"&Server.MapPath("backup")&""&"backuptext.dat"&"'"
setcnn=Server.createobject("adodb.connection")
cnn.open"driver={SQLServer};Server=服务器名;uid=sa;pwd="
cnn.executeSQL
onerrorresumenext
iferr<>0then
response.write"错误:"&err.Descripting
else
response.write"数据备份成功!"
endif
%>绿色chinaipower.comAYrCJ6B
2、恢复
<%
SQL="Restoredatabase数据库名fromdisk='"&Server.MapPath("backup")&""&"backuptext.dat"&"'"
setcnn=Server.createobject("adodb.connection")
cnn.open"driver={SQLServer};Server=服务器名;uid=sa;pwd="
cnn.executeSQL
onerrorresumenext
iferr<>0then
response.write"错误:"&err.Descripting
else
response.write"数据恢复成功!"
endif
%>