ASP Database Recovery Code

Source: Internet
Author: User
Tags exit empty generator microsoft frontpage visual studio
Recovery | data | database


File 4:restoredb.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 ("' Restore from ' is empty!")
Frmbak.txtto.focus
Exit Sub
End If
Frmbak.submit
End Sub

-->
</SCRIPT>
</HEAD>
<form action= "restoredbsave.asp" method= "POST" Id=frmbak name=frmbak>
<body class= "Bg_frame_up" >
<link rel= "stylesheet" href= ". /.. /sheets/b2bstyle.css ">

<p class=heading> Database--> restore</p>

<p align=center>
<div align= "center" >
<center>
<table width= "60%" height= "a" cellpadding=1 cellspacing=1 border=0 align=center>
<tr>
&LT;TD class=td_mand_fn align= "center" height= width= "40%" >server name:</td>
&LT;TD class=td_mand_f height= ">"
<input id=txtsvr name=txtsvr size= "style=" font-family:arial; Font-size:9pt "></td>
</tr>
<tr>
&LT;TD class=td_mand_fn align= "center" height= "Width=" >Administrators:</td>
&LT;TD class=td_mand_f height= ">"
<input id=txtuid name=txtuid style= "font-family:arial; Font-size:9pt "></td>
</tr>
<tr>
&LT;TD class=td_mand_fn align= "center" height= "Width=" >Password:</td>
&LT;TD class=td_mand_f height= ">"
<input id=txtpwd name=txtpwd type=password style= "font-family:arial; Font-size:9pt "></td>
</tr>
<tr>
&LT;TD class=td_mand_fn align= "center" height= "Width=" >Database:</td>
&LT;TD class=td_mand_f height= ">"
<input id=txtdb name=txtdb style= "font-family:arial; Font-size:9pt "></td>
</tr>
<tr>
&LT;TD class=td_mand_fn align= "center" height= "width= 40%" >restore
From:<br>
<u> (Server Path) </u></td>
&LT;TD class=td_mand_f height= ">"
<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 Restore" style= "font-family:arial; Font-size:9pt "></p>
</body>
</form>
</HTML>

File 5:restoredbsave.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.") SQL Server ")
Dmosvr.connect msvr,muid,mpwd

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

Mdevname= "Restore_" &muid& "_" &mdb
Dmosvr.backupdevices (mdevname). Remove
Err.Clear

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 Dmores=server. CreateObject ("SQLDMO.") Restore ")
Dmores.database=mdb
Dmores.devices=mdevname
%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<body class= "Bg_frame_up" >

<p><strong>restoring, wait please...</strong></p>
<%
Dmores.sqlrestore Dmosvr
If Err.number>0 then Response.Redirect ("http:backuperr.asp?err=" &err.number)

Set dmores=nothing
Set dmodev=nothing
Dmosvr.disconnect
Set dmosvr=nothing
%>
<p><strong>database ' <%=mdb%> ' Restore successed!</strong></p>
</BODY>
</HTML>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.