用ASP備份資料庫

來源:互聯網
上載者:User
備份|資料|資料庫 檔案1:BackupDB.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Sub btnbak_onclick
if frmbak.txtsvr.value="" then
window.alert("'Server Name' is empty!")
frmbak.txtsvr.focus
exit sub
end if
if frmbak.txtuid.value="" then
window.alert("'Administrators' is empty!")
frmbak.txtuid.focus
exit sub
end if
if frmbak.txtdb.value="" then
window.alert("'Database' is empty!")
frmbak.txtdb.focus
exit sub
end if
if frmbak.txtto.value="" then
window.alert("'Backup To' is empty!")
frmbak.txtto.focus
exit sub
end if
frmbak.submit
End Sub

-->
</SCRIPT>
<link rel="stylesheet" href="../../sheets/B2BStyle.css">
</HEAD>
<form action="backupdbsave.asp" method="post" id=frmbak name=frmbak>
<body class="bg_frame_up">
<p class=heading> Database --> Backup</p>
<P align=center>
<div align="center">
<center>
<table width="60%" cellpadding=1 cellspacing=1 border=0 align=center>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">Server Name:</td>
<td class=TD_Mand_F height="35" width="59%">
<INPUT id=txtsvr name=txtsvr size="20" style="font-family: Arial; font-size: 9pt"></td>
</tr>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">Administrators:</td>
<td class=TD_Mand_F height="35" width="59%">
<INPUT id=txtuid name=txtuid size="20" style="font-family: Arial; font-size: 9pt"></td>
</tr>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">Password:</td>
<td class=TD_Mand_F height="35" width="59%">
<INPUT id=txtpwd name=txtpwd type=password style="font-family: Arial; font-size: 9pt"></td>
</tr>
<tr>
<td class=TD_Mand_FN align="center" height="35" width="40%">Database:</td>
<td class=TD_Mand_F height="35" width="59%">
<p align="left">
<INPUT id=txtdb name=txtdb size="20" style="font-family: Arial; font-size: 9pt"></p>
</td>
</tr>

<td class=TD_Mand_FN align="center" height="35" width="40%">Backup To:<br>
<u>(Server Path)</u></td>
<td class=TD_Mand_F height="35" width="59%">
<input id=txtto name=txtto style="font-family: Arial; font-size: 9pt"></td>
</tr>
</table>
</center> </div>
<p align=center><input id=btnbak name=btnbak type=button value="Start Backup" style="font-family: Arial; font-size: 9pt"></p>
</body>
</form>
</HTML>


檔案2:BackupDBSave.asp

<%@ Language=VBScript %>
<%
dim msvr,muid,mpwd,mdb,mto
msvr=Request.Form("txtsvr")
muid=Request.Form("txtuid")
mpwd=Request.Form("txtpwd")
mdb=Request.Form("txtdb")
mto=Request.Form("txtto")
if mpwd="" then mpwd="''"

on error resume next
set dmosvr=server.CreateObject("SQLDMO.SQLServer")
dmosvr.connect msvr,muid,mpwd

if err.number>0 then Response.Redirect("http:backuperr.asp?err="&err.number)

mdevname="Backup_"&muid&"_"&mdb
set dmodev=server.CreateObject("SQLDMO.BackupDevice")
dmodev.name=mdevname
dmodev.type=2
dmodev.PhysicalLocation=mto
dmosvr.BackupDevices.Add dmodev

if err.number>0 then Response.Redirect("http:backuperr.asp?err="&err.number)

set dmobak=server.CreateObject("SQLDMO.Backup")
dmobak.database=mdb



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.