ASP实现SQL备份、恢复
2018-09-06 12:59
1、备份
<%
SQL=backupdatabase数据库名todisk=&Server.MapPath(backup)&\\&backuptext.dat&
cnn.opendriver={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.opendriver={SQLServer};Server=服务器名;uid=sa;pwd=
cnn.executeSQL
onerrorresumenext
iferr<>0then
response.write错误:&err.Descripting
else
response.write数据恢复成功!
endif
%>