非常好用的asp备份,还原SQL数据库的代码(2)
end if
if act="restore" then
'恢复时要在没有使用数据库时进行!
set srv=server.createobject("sqldmo.sqlserver")
srv.logintimeout = sqllogintimeout
srv.connect sqlserver,sqlname, sqlpassword
set rest=server.createobject("sqldmo.restore")
rest.action=0 ' full db restore
rest.database=databasename
rest.devices=files
rest.files=bak_file
rest.replacedatabase=true 'force restore over existing database
if err.number>0 then
response.write err.number&"<font color=red><br>"
response.write err.description&"</font>"
end if
rest.sqlrestore srv
response.write "<font color=green>恢复成功!</font>"
else
response.write "<font color=red>没有选择操作</font>"
end if
end if
end if
%>
内容版权声明:除非注明,否则皆为本站原创文章。