|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP脚本是采用明文(plaintext)方式来编写的。备份|数据|数据库
文件1:BackupDB.asp
<%@Language=VBScript%>
<HTML>
<HEAD>
<METAname=VI60_defaultClientScriptcontent=VBScript>
<METANAME="GENERATOR"Content="MicrosoftFrontPage4.0">
<SCRIPTID=clientEventHandlersVBSLANGUAGE=vbscript>
<!--
Subbtnbak_onclick
iffrmbak.txtsvr.value=""then
window.alert("ServerNameisempty!")
frmbak.txtsvr.focus
exitsub
endif
iffrmbak.txtuid.value=""then
window.alert("Administratorsisempty!")
frmbak.txtuid.focus
exitsub
endif
iffrmbak.txtdb.value=""then
window.alert("Databaseisempty!")
frmbak.txtdb.focus
exitsub
endif
iffrmbak.txtto.value=""then
window.alert("BackupToisempty!")
frmbak.txtto.focus
exitsub
endif
frmbak.submit
EndSub
-->
</SCRIPT>
<linkrel="stylesheet"href="../../sheets/B2BStyle.CSS">
</HEAD>
<formaction="backupdbsave.asp"method="post"id=frmbakname=frmbak>
<bodyclass="bg_frame_up">
<pclass=heading>Database-->Backup</p>
<Palign=center>
<divalign="center">
<center>
<tablewidth="60%"cellpadding=1cellspacing=1border=0align=center>
<tr>
<tdclass=TD_Mand_FNalign="center"height="35"width="40%">ServerName:</td>
<tdclass=TD_Mand_Fheight="35"width="59%">
<INPUTid=txtsvrname=txtsvrsize="20"style="font-family:Arial;font-size:9pt"></td>
</tr>
<tr>
<tdclass=TD_Mand_FNalign="center"height="35"width="40%">Administrators:</td>
<tdclass=TD_Mand_Fheight="35"width="59%">
<INPUTid=txtuidname=txtuidsize="20"style="font-family:Arial;font-size:9pt"></td>
</tr>
<tr>
<tdclass=TD_Mand_FNalign="center"height="35"width="40%">Password:</td>
<tdclass=TD_Mand_Fheight="35"width="59%">
<INPUTid=txtpwdname=txtpwdtype=passwordstyle="font-family:Arial;font-size:9pt"></td>
</tr>
<tr>
<tdclass=TD_Mand_FNalign="center"height="35"width="40%">Database:</td>
<tdclass=TD_Mand_Fheight="35"width="59%">
<palign="left">
<INPUTid=txtdbname=txtdbsize="20"style="font-family:Arial;font-size:9pt"></p>
</td>
</tr>
<tdclass=TD_Mand_FNalign="center"height="35"width="40%">BackupTo:<br>
<u>(ServerPath)</u></td>
<tdclass=TD_Mand_Fheight="35"width="59%">
<inputid=txttoname=txttostyle="font-family:Arial;font-size:9pt"></td>
</tr>
</table>
</center></div>
<palign=center><inputid=btnbakname=btnbaktype=buttonvalue="StartBackup"style="font-family:Arial;font-size:9pt"></p>
</body>
</form>
</HTML>
文件2:BackupDBSave.asp
<%@Language=VBScript%>
<%
dimmsvr,muid,mpwd,mdb,mto
msvr=Request.Form("txtsvr")
muid=Request.Form("txtuid")
mpwd=Request.Form("txtpwd")
mdb=Request.Form("txtdb")
mto=Request.Form("txtto")
ifmpwd=""thenmpwd=""
onerrorresumenext
setdmosvr=server.CreateObject("SQLDMO.SQLServer")
dmosvr.connectmsvr,muid,mpwd
iferr.number>0thenResponse.Redirect("http:backuperr.asp?err="&err.number)
mdevname="Backup_"&muid&"_"&mdb
setdmodev=server.CreateObject("SQLDMO.BackupDevice")
dmodev.name=mdevname
dmodev.type=2
dmodev.PhysicalLocation=mto
dmosvr.BackupDevices.Adddmodev
iferr.number>0thenResponse.Redirect("http:backuperr.asp?err="&err.number)
setdmobak=server.CreateObject("SQLDMO.Backup")
dmobak.database=mdb
dmobak.devices=mdevname
%>
<HTML>
<HEAD>
<METANAME="GENERATOR"Content="MicrosoftVisualStudio6.0">
</HEAD>
<bodybackground="../../Images/dot.gif">
<p><strong>Backuping,waitplease...</strong></p>
<%
dmobak.sqlbackupdmosvr
iferr.number>0thenResponse.Redirect("http:backuperr.asp?err="&err.number)
dmosvr.backupdevices(mdevname).remove
setdmobak=nothing
setdmodev=nothing
dmosvr.disconnect
setdmosvr=nothing
%>
<p><strong>Database<%=mdb%>backupsuccessed!</strong></p>
</BODY>
</HTML>
文件3:BackupErr.asp
<%@Language=VBScript%>
<%
dimerrno,errstr
errno=Request.QueryString("err")
errstr=""
selectcasecstr(errno)
case"18456"
errstr="administratorsorpassworderror!"
case"20482"
errstr="servernameerrororservercannotconnect!"
case"911"
errstr="databasenotfound!"
case"15026"
errstr="serverpathnotfound!"
case"3201"
errstr="serverpathnotfound!"
case"3254"
errstr="restorefromfilelawlessness!"
caseelse
errstr="unknownerror!retrylaterplease!"
endselect
%>
<HTML>
<HEAD>
<METAname=VI60_defaultClientScriptcontent=VBScript>
<METANAME="GENERATOR"Content="MicrosoftFrontPage4.0">
<SCRIPTID=clientEventHandlersVBSLANGUAGE=vbscript>
<!--
Subbtnret_onclick
history.back
EndSub
-->
</SCRIPT>
<title></title>
</HEAD>
<bodyclass="bg_frame_up">
<palign=center><fontcolor=#006666><%=errstr%></font></p>
<palign=center><inputid=btnretname=btnrettype=buttonvalue=Returnstyle="font-family:Arial;font-size:9pt"></p>
</BODY>
</HTML>
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 |
|