日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
ASP.NET中SQLServer數(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ù)庫備份之后我們會(huì)遇到恢復(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)容就向你介紹到這里,希望對(duì)你有所幫助。


文章名稱:ASP.NET中SQLServer數(shù)據(jù)庫備份恢復(fù)淺析
標(biāo)題鏈接:http://www.5511xx.com/article/cciogsj.html