采飛揚(yáng)ASP備份MSSQL數(shù)據(jù)庫程序 V1.0

[重要通告]如您遇疑難雜癥,本站支持知識(shí)付費(fèi)業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時(shí)間哦!

采飛揚(yáng)ASP備份MSSQL數(shù)據(jù)庫程序 V1.0

 
XML/HTML代碼
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  6. <title>采飛揚(yáng)ASP備份MSSQL數(shù)據(jù)庫程序 V1.0--QQ:79998575</title>  
  7. </head>  
  8. <style>  
  9. BODY {        FONT-SIZE: 9pt;        COLOR: #000000;        FONT-FAMILY: "Courier New";        scrollbar-face-color:#E4E4F3;        scrollbar-highlight-color:#FFFFFF;        scrollbar-3dlight-color:#E4E4F3;        scrollbar-darkshadow-color:#9C9CD3;        scrollbar-shadow-color:#E4E4F3;        scrollbar-arrow-color:#4444B3;        scrollbar-track-color:#EFEFEF;}TABLE {        FONT-SIZE: 9pt;        FONT-FAMILY: "Courier New";        BORDER-COLLAPSE: collapse;        border-top-width: 1px;        border-right-width: 1px;        border-bottom-width: 1px;        border-left-width: 1px;        border-top-style: solid;        border-right-style: none;        border-bottom-style: none;        border-left-style: solid;        border-top-color: #d8d8f0;        border-right-color: #d8d8f0;        border-bottom-color: #d8d8f0;        border-left-color: #d8d8f0;}.tr {        font-family: "Courier New";        font-size: 9pt;        background-color: #e4e4f3;        text-align: center;}.td {        font-family: "Courier New";        font-size: 9pt;        background-color: #f9f9fd;}.warningColor {        font-family: "Courier New";        font-size: 9pt;        color: #ff0000;}input {   
  10.         font-family: "Courier New";   
  11.         BORDER-TOP-WIDTH: 1px;   
  12.         BORDER-LEFT-WIDTH: 1px;   
  13.         FONT-SIZE: 12px;   
  14.         BORDER-BOTTOM-WIDTH: 1px;   
  15.         BORDER-RIGHT-WIDTH: 1px;   
  16.         color: #000000;   
  17. }textarea {        font-family: "Courier New";        BORDER-TOP-WIDTH: 1px;        BORDER-LEFT-WIDTH: 1px;        FONT-SIZE: 12px;        BORDER-BOTTOM-WIDTH: 1px;        BORDER-RIGHT-WIDTH: 1px;        color: #000000;}.liuyes {   
  18.         background-color: #CCCCFF;   
  19. }   
  20. A:link {        FONT-SIZE: 9pt;         COLOR: #000000;        FONT-FAMILY: "Courier New";         TEXT-DECORATION: none;}tr {        font-family: "Courier New";        font-size: 9pt;        line-height: 18px;}td {        font-family: "Courier New";        font-size: 9pt;        border-top-width: 1px;        border-right-width: 1px;        border-bottom-width: 1px;        border-left-width: 1px;        border-top-style: none;        border-right-style: solid;        border-bottom-style: solid;        border-left-style: none;        border-top-color: #d8d8f0;        border-right-color: #d8d8f0;        border-bottom-color: #d8d8f0;        border-left-color: #d8d8f0;}.trHead {        font-family: "Courier New";        font-size: 9pt;        background-color: #e4e4f3;        line-height: 3px;}.inputLogin {        font-family: "Courier New";        font-size: 9pt;        border: 1px solid #d8d8f0;        background-color: #f9f9fd;        vertical-align: bottom;}</style>  
  21. <body>  
  22. <form method="post" name="myform" action="?action=backupdatabase">  
  23. <table width="686" border="1" align="center">  
  24.   <tr>  
  25.     <td width="613" height="30" align="center" bgcolor="#330066"><font color="#FFFFFF">采飛揚(yáng)ASP備份MSSQL數(shù)據(jù)庫程序 V1.0 </font></td>  
  26.   </tr>  
  27.   <tr>  
  28.     <td>選擇操作:   
  29.       <input type="radio" name="act" id="act_backup"value="backup" />  
  30.       <label for=act_backup>備份</label>  
  31.       <input type="radio" name="act" id="act_restore" value="restore" />  
  32.       <label for=act_restore>恢復(fù)</label></td>  
  33.   </tr>  
  34.   <tr>  
  35.     <td><label>SQL服務(wù)器:   
  36.         <input type="text" name="sqlserver" value="localhost" />  
  37.     </label></td>  
  38.   </tr>  
  39.   <tr>  
  40.     <td><label>用戶名:   
  41.         <input name="sqlname" type="text" value="sa" />  
  42.     密  碼:   
  43.     <input type="text" name="sqlpassword" />  
  44. </label></td>  
  45.   </tr>  
  46.   <tr>  
  47.     <td><label>數(shù)據(jù)庫名:   
  48.         <input type="text" name="databasename" value="<%=request("databasename")%>" />  
  49.     </label></td>  
  50.   </tr>  
  51.   <tr>  
  52.     <td>文件路徑:   
  53.       <input name="bak_file" type="text" value="<% =server.MapPath("\")&"\"&"jzpu.bak"%>size="60" />  
  54. (備份或恢復(fù)的文件路徑)</td>  
  55.   </tr>  
  56.   <tr>  
  57.     <td><% Response.write "本文件絕對(duì)路徑:" %>  
  58.       <font color="#FF0000">  
  59.       <% =server.mappath(Request.ServerVariables("SCRIPT_NAME")) %>  
  60.       </font></td>  
  61.   </tr>  
  62.   <tr>  
  63.     <td><input name=submit1 type="submit" class="liuyes" id=submit1 size="10" value="確  定" />  
  64.          <input name="Submit" type="reset" class="liuyes" size="10" value="重  置" /></td>  
  65.   </tr>  
  66. </table>  
  67. </form>    
  68. <table width="686" border="1" align="center">  
  69.   <tr>  
  70.     <td>提示信息:<%    
  71. if request("action")="" then           
  72.   response.write "<font color=#ff0000>不用我多說什么了吧!</font>"   
  73. end if   
  74. 'SQL Server 數(shù)據(jù)庫的備份與恢復(fù)!    
  75. if request("action")="backupdatabase" Then    
  76. dim sqlserver,sqlname,sqlpassword,sqlLoginTimeout,databasename,bak_file,act    
  77. sqlserver = trim(request("sqlserver"))   
  78. sqlname = trim(request("sqlname"))   
  79. sqlpassword =trim(request("sqlpassword"))   
  80. sqlLoginTimeout = 15  
  81. databasename = trim(request("databasename"))    
  82. bak_file = trim(request("bak_file"))    
  83. bak_file = replace(bak_file,"$1",databasename)   
  84. act = lcase(request("act"))   
  85. if databasename = "" then   
  86. response.write "<font color=#ff0000>沒有輸入數(shù)據(jù)庫名稱!</font>"   
  87. else   
  88. if act = "backup" then   
  89. Set srv=Server.CreateObject("SQLDMO.SQLServer")   
  90. srv.LoginTimeout = sqlLoginTimeout  
  91. srv.Connect sqlserver,sqlname, sqlpassword   
  92. Set bak = Server.CreateObject("SQLDMO.Backup")   
  93. bak.Database=databasename  
  94. bak.Devices=Files    
  95. bak.Action   = 0  
  96. bak.Initialize   = 1  
  97. 'bak.Replace        = True  
  98. bak.Files=bak_file    
  99. bak.SQLBackup srv   
  100. if err.number>0 then    
  101. response.write err.number&"<font color=red><br>"    
  102. response.write err.description&"</font>"    
  103. end if   
  104. Response.write "<font color=green>備份成功!</font>"    
  105. elseif act="restore" then   
  106. '恢復(fù)時(shí)要在沒有使用數(shù)據(jù)庫時(shí)進(jìn)行!    
  107. Set srv=Server.CreateObject("SQLDMO.SQLServer")   
  108. srv.LoginTimeout = sqlLoginTimeout  
  109. srv.Connect sqlserver,sqlname, sqlpassword   
  110. Set rest=Server.CreateObject("SQLDMO.Restore")   
  111. rest.Action=0 ' full db restore    
  112. rest.Database=databasename    
  113. rest.Devices=Files    
  114. rest.Files=bak_file    
  115. rest.ReplaceDatabase=True 'Force restore over existing database    
  116. if err.number>0 then   
  117. response.write err.number&"<font color=red><br>"   
  118. response.write err.description&"</font>"   
  119. end if   
  120. rest.SQLRestore srv   
  121. Response.write "<font color=green>恢復(fù)成功!</font>"   
  122. else    
  123. Response.write "<font color=red>請選擇備份或恢復(fù)!</font>"   
  124. end if    
  125. end if    
  126. end if   
  127. %></td>  
  128.   </tr>  
  129. </table>    
  130. </body>  
  131. </html>  

問題未解決?付費(fèi)解決問題加Q或微信 2589053300 (即Q號(hào)又微信號(hào))右上方掃一掃可加博主微信

所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!

支付寶贊助
微信贊助

免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。

您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對(duì)《免責(zé)聲明》全部內(nèi)容的認(rèn)可->聯(lián)系老梁投訴資源
LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。 敬請諒解! 侵權(quán)刪帖/違法舉報(bào)/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評(píng)論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » 采飛揚(yáng)ASP備份MSSQL數(shù)據(jù)庫程序 V1.0

發(fā)表回復(fù)

本站承接,網(wǎng)站推廣(SEM,SEO);軟件安裝與調(diào)試;服務(wù)器或網(wǎng)絡(luò)推薦及配置;APP開發(fā)與維護(hù);網(wǎng)站開發(fā)修改及維護(hù); 各財(cái)務(wù)軟件安裝調(diào)試及注冊服務(wù)(金蝶,用友,管家婆,速達(dá),星宇等);同時(shí)也有客戶管理系統(tǒng),人力資源,超市POS,醫(yī)藥管理等;

立即查看 了解詳情