Backup in ASP. NET
When developing a website, in the management background, the Administrator usually regularly backs up the database (of course, The sqlserver server can also perform regular automatic backup, but here I am talking about ASP. NET), the backup code is very simple:
The following is an event that I wrote under the "backup" button when I made a website background:
- Protectedvoidbutton#click (objectsender, EventArgse)
- ...{
- Stringnewname="WebJake"+ DateTime. Now. Year. ToString () +
DateTime. Now. Month. ToString () + DateTime. Now. Day. ToString () +
DateTime. Now. Hour. ToString () + ". bak ";
- SqlConnectioncn=DB. CreateCon ();
- Stringnepath=Server. MapPath (".../../DataBack/") + newname;
- Stringsql="BACKUPDATABASEWebJaketoDISK = '"+ Nepath + "'";
- SqlCommandcmd=NewSqlCommand(SQL, cn );
- Try
- ...{
- Cn. Open ();
- Cmd. ExecuteNonQuery ();
- HyperLink1.Text="The backup has been successfully backed up to the server path :"+ Nepath + "click to download to local! ";
- HyperLink1.NavigateUrl=".../DataBack /"+ Newname;
- HyperLink1.Visible=True;
- }
- Catch (Exceptionex)
- ...{
- Stringexm= Ex. Message;
- Label1.Text="An error occurred while backing up the database. This file may not exist! ";
- Label1.Visible=True;
- }
- Finally
- ...{
- Cmd. Dispose ();
- Cn. Close ();
- Cn. Dispose ();
- }
- }
Of course, the most important thing is this sentence:
Backup database WebJake to DISK = 'path you want to save '. The above describes the BACKUP in ASP. NET.
- Analysis on PageBase and MasterPage of ASP. NET
- XML Web Service Method of ASP. NET
- Detailed description of ASP. NET environment deployment
- Implement ASP. NET globalization
- Solve the Problem of ASP. net ajax script errors