自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP.NET中SQL Server數(shù)據(jù)庫備份恢復(fù)淺析

開發(fā) 后端
SQL Server數(shù)據(jù)庫備份恢復(fù)對于編程人員來說是經(jīng)常碰到的問題,那么如何處理呢?我們將在本文中向你介紹處理SQL Server數(shù)據(jù)庫備份恢復(fù)的程序源碼。

ASP.NET中SQL Server數(shù)據(jù)庫備份恢復(fù)的操作是如何的呢?首先我們來看看在ASP.NET中是怎么進(jìn)行SQL Server數(shù)據(jù)庫備份的。

以下是進(jìn)行SQL Server數(shù)據(jù)庫備份引用片段:

  1.   string SqlStr1 = "Server=(local);
  2. database='" + this.DropDownList1.SelectedValue + "';
  3. Uid=sa;Pwd=";   
  4.   string SqlStr2 = "backup database " + 
  5. this.DropDownList1.SelectedValue + " to disk='" + 
  6. this.TextBox1.Text.Trim() + ".bak'";   
  7.   SqlConnection con = new SqlConnection(SqlStr1);   
  8.   con.Open();   
  9.   try   
  10.   {   
  11.   if (File.Exists(this.TextBox1.Text.Trim()))   
  12.   {   
  13.   Response.Write(" ");   
  14.   return;   
  15.   }   
  16.   SqlCommand com = new SqlCommand(SqlStr2, con);   
  17.   com.ExecuteNonQuery();   
  18.   Response.Write(" ");   
  19.   }   
  20.   catch (Exception error)   
  21.   {   
  22.   Response.Write(error.Message);   
  23.   Response.Write(" ");   
  24.   }   
  25.   finally   
  26.   {   
  27.   con.Close();   
  28.   }  

那么在ASP.NET中SQL Server數(shù)據(jù)庫備份之后我們會遇到恢復(fù)數(shù)據(jù)庫的操作,下面呢就是SQL Server數(shù)據(jù)庫備份恢復(fù)的源碼:

  1.   string path = this.FileUpload1.PostedFile.FileName; //獲得備份路徑及數(shù)據(jù)庫名稱   
  2.   string dbname = this.DropDownList1.SelectedValue;   
  3.   string SqlStr1 = "Server=(local);
  4. database='" + this.DropDownList1.SelectedValue + "';
  5. Uid=sa;Pwd=";   
  6.   string SqlStr2 = "use master restore database " + dbname + " from disk='" + path + "'";   
  7.   SqlConnection con = new SqlConnection(SqlStr1);   
  8.   con.Open();   
  9.   try   
  10.   {   
  11.   SqlCommand com = new SqlCommand(SqlStr2, con);   
  12.   com.ExecuteNonQuery();   
  13.   Response.Write(" ");   
  14.   }   
  15.   catch (Exception error)   
  16.   {   
  17.   Response.Write(error.Message);   
  18.   Response.Write(" ");   
  19.   }   
  20.   finally   
  21.   {   
  22.   con.Close();   
  23.   }  

ASP.NET中SQL Server數(shù)據(jù)庫備份恢復(fù)的相關(guān)內(nèi)容就向你介紹到這里,希望對你有所幫助。

【編輯推薦】

  1. ASP.NET數(shù)據(jù)驗(yàn)證技術(shù)研究詳解
  2. ASP.NET代碼分離之網(wǎng)站建設(shè)應(yīng)用淺析
  3. ASP.NET代碼優(yōu)化淺析
  4. ASP.NET數(shù)據(jù)驗(yàn)證控件CustomValidator的使用淺析
  5. ASP.NET網(wǎng)頁中的嵌入式代碼塊應(yīng)用淺析
責(zé)任編輯:仲衡 來源: 網(wǎng)頁設(shè)計(jì)
相關(guān)推薦

2009-07-31 09:57:47

ASP.NET數(shù)據(jù)庫緩

2009-07-28 17:36:21

ASP.NET數(shù)據(jù)庫連

2009-07-29 09:12:31

ASP.NET數(shù)據(jù)庫連

2009-07-27 17:58:10

ASP.NET數(shù)據(jù)庫編

2009-07-31 10:29:57

ASP.NET數(shù)據(jù)庫操

2009-07-28 11:00:24

Excel導(dǎo)入SQL

2009-07-29 09:33:14

ASP.NET數(shù)據(jù)庫連

2010-07-08 11:05:14

SQL Server數(shù)

2009-09-03 19:30:02

ASP.NET數(shù)據(jù)庫SQL Server

2009-08-12 11:04:38

ASP.NET和SQL

2009-07-24 10:10:22

ASP.NET

2009-07-28 16:31:03

Windows 200

2023-09-05 00:06:45

2009-07-31 16:09:23

ASP.NET數(shù)據(jù)庫圖

2010-05-25 08:49:33

連接MySQL

2009-08-03 18:35:51

ASP.NET數(shù)據(jù)緩存

2009-07-24 13:41:15

ASP.NET AJA

2009-08-05 18:36:12

ASP.NET Che

2009-07-31 12:43:59

ASP.NET MVC

2009-08-05 15:50:13

ASP.NET優(yōu)點(diǎn)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號