日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
ASP.NET中SQLServer數(shù)據(jù)庫(kù)備份恢復(fù)淺析

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

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

 
 
 
  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ù)庫(kù)備份之后我們會(huì)遇到恢復(fù)數(shù)據(jù)庫(kù)的操作,下面呢就是SQL Server數(shù)據(jù)庫(kù)備份恢復(fù)的源碼:

 
 
 
  1.   string path = this.FileUpload1.PostedFile.FileName; //獲得備份路徑及數(shù)據(jù)庫(kù)名稱   
  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ù)庫(kù)備份恢復(fù)的相關(guān)內(nèi)容就向你介紹到這里,希望對(duì)你有所幫助。


本文名稱:ASP.NET中SQLServer數(shù)據(jù)庫(kù)備份恢復(fù)淺析
網(wǎng)頁(yè)鏈接:http://www.dlmjj.cn/article/cciogsj.html