asp.net和c#实现定时备份数据库(SQL Server2000)

时间:2022-01-28 13:40:29

http://hi.baidu.com/xqaizx1314/blog/item/c1e6e10b1bd71988d1581bb0.html

 

 

其实很简单,只需要用到javascript,因为.net的webform的后台代码无法调用cmd.exe。  
你最多在用脚本在添加点时间控制的代码。  
我这里是对orcle的备份  
----------------------------------------------------------------------------  
<script   language   =vbscript>  
dim   expstr  
select   case   Weekday(date)  
case   1    
expstr   =   "jlsbgis/jlsbgis@sj   owner=jlsbgis   file=D:/database/sj"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
case   2    
expstr   =   "jlsbgis/jlsbgis@spgd   owner=jlsbgis   file=D:/database/spgd"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"  
case   3  
expstr   =   "jlsbgis/jlsbgis@jlgd   owner=jlsbgis   file=D:/database/jlgd"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
case   4    
expstr   =   "jlsbgis/jlsbgis@spgd   owner=jlsbgis   file=D:/database/spgd"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
case   5  
expstr   =   "jlsbgis/jlsbgis@bsgd   owner=jlsbgis   file=D:/database/bsgd"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
case   6  
expstr   =   "jlsbgis/jlsbgis@sj   owner=jlsbgis   file=D:/database/sj"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
case   7  
expstr   =   "jlsbgis/jlsbgis@thgd   owner=jlsbgis   file=D:/database/thgd"   &   year(date)   &   month(date)   &   day(date)   &   ".dmp   log=c:/temp/expost.log"    
end   select  
set   objshell   =   CreateObject("Shell.Application")  
objshell.shellexecute   "exp",   expstr  
if   err.number   <>   0   then  
msgbox   "oracle   可能出现问题,请询问黄总。"   &   chr(10)   &chr(10)   &   "错误代码:"   &   err.Description   ,,"提示"  
end   if  
set   objShell   =   nothing  
</script>