In the Web, security is mainly embodied in two aspects: one is the program security, that is, to prevent the Web page in the insertion of malicious code, the other is database security, which we can often back up the database to achieve.
In the article, I'll show you how to back up and restore a database in a Web page.
In fact, backup and recovery databases are backed up by SQL Server-supplied SQL statements.
Backup: Use Master;backup database @name to disk= @path;
Recovery: Use Master;restore database @name the @path from disk=;
The above is a parameterized SQL statement that can be dynamically assigned to a parameter when the program executes.
Code:
<%@ Page language= "C # autoeventwireup=" true "codefile=" DatabaseAction.aspx.cs "inherits=" Databaseaction "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
<title> Untitled Page </title>
<body>
<form id= "Form1" runat= "Server"
<div>
<table border= "0" width= "100%"
<tr><td colspan= "2" > Database restore and Backup </td></tr>
<tr ><td> Please select database </td><td>
<asp:dropdownlist id= "ddldatabaselist" runat= "Server"
& Lt;/asp:dropdownlist></td></tr>
<tr><td>
Database file name </td><td>
& Lt;asp:textbox id= "Txtdbfilename" runat= "Server" ></ASP:TEXTBOX></TD></TR>
<tr>< Td>
Action Options </td> <td>
<asp:radiobutton id= "rbbackup" runat= "Server" checked= "True" groupname= "action" text= "Backup"/>
<asp:radiobutton id= "Rbrestore" runat= "Server" groupname= "action" text= "restore"/></TD></TR>
<tr><td>
Operation </td><td>
<asp:button id= "Btnok" runat= "Server" onclick= "btnOK_ Click text= "Execute"/></td></tr>
</table>
</div>
</form>
</body& Gt