最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET下備份與還原數(shù)據(jù)庫(kù)代碼

 更新時(shí)間:2010年03月10日 23:01:40   作者:  
ASP.NET下備份還原數(shù)據(jù)庫(kù)的實(shí)現(xiàn)代碼,需要的朋友可以參考下。
核心技術(shù):
復(fù)制代碼 代碼如下:

using System.Data.SqlClient;
using System.IO;
string SqlStr1 = "Server=(local);DataBase=master;Uid=sa;Pwd=";
string SqlStr2 = "Exec sp_helpdb";
string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";
string SqlStr2 = "backup database " + this.DropDownList1.SelectedValue + " to disk='" + this.TextBox1.Text.Trim() + ".bak'";

1.前臺(tái)
復(fù)制代碼 代碼如下:

<table>
<tr>
<td style="width: 100px"><span style="font-size: 9pt">操 作 數(shù) 據(jù) 庫(kù)</span></td>
<td><asp:DropDownList ID="DropDownList1" runat="server" Font-Size="9pt" Width="124px"></asp:DropDownList></td>
<td style="width: 100px"></td>
</tr>
<tr>
<td style="width: 100px"><span style="font-size: 9pt">備份名稱和位置</span></td>
<td style="width: 100px"><asp:TextBox ID="TextBox1" runat="server" Font-Size="9pt" Width="117px"></asp:TextBox></td>
<td style="width: 100px"><span style="font-size: 9pt; color: #ff3300">(如D:\beifen)</span></td>
</tr>
<tr>
<td colspan="3"><asp:Button ID="Button1" runat="server" Font-Size="9pt" OnClick="Button1_Click" Text="備份數(shù)據(jù)庫(kù)" /></td>
</tr>
</table>

2.后臺(tái)
復(fù)制代碼 代碼如下:

using System.Data.SqlClient;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string SqlStr1 = "Server=(local);DataBase=master;Uid=sa;Pwd=";
string SqlStr2 = "Exec sp_helpdb";
SqlConnection con = new SqlConnection(SqlStr1);
con.Open();
SqlCommand com = new SqlCommand(SqlStr2, con);
SqlDataReader dr = com.ExecuteReader();
this.DropDownList1.DataSource = dr;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataBind();
dr.Close();
con.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";
string SqlStr2 = "backup database " + this.DropDownList1.SelectedValue + " to disk='" + this.TextBox1.Text.Trim() + ".bak'";
SqlConnection con = new SqlConnection(SqlStr1);
con.Open();
try
{
if (File.Exists(this.TextBox1.Text.Trim()))
{
Response.Write("<script language=javascript>alert('此文件已存在,請(qǐng)從新輸入!');location='Default.aspx'</script>");
return;
}
SqlCommand com = new SqlCommand(SqlStr2, con);
com.ExecuteNonQuery();
Response.Write("<script language=javascript>alert('備份數(shù)據(jù)成功!');location='Default.aspx'</script>");
}
catch (Exception error)
{
Response.Write(error.Message);
Response.Write("<script language=javascript>alert('備份數(shù)據(jù)失??!')</script>");
}
finally
{
con.Close();
}
}
}



還原SqlServer
核心技術(shù):
復(fù)制代碼 代碼如下:

string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";
string SqlStr2 = "use master restore database " + dbname + " from disk='" + path + "'";

1.前臺(tái)
復(fù)制代碼 代碼如下:

<table>
<tr>
<td style="width: 100px; height: 21px"><span style="font-size: 9pt">操 作 數(shù) 據(jù) 庫(kù)</span></td>
<td><asp:DropDownList ID="DropDownList1" runat="server" Font-Size="9pt" Width="124px"></asp:DropDownList></td>
<td style="width: 100px; height: 21px"></td>
</tr>
<tr>
<td style="width: 100px"><span style="font-size: 9pt">操 作 數(shù) 據(jù) 庫(kù)</span></td>
<td style="width: 100px"><asp:FileUpload ID="FileUpload1" runat="server" Font-Size="9pt" Width="190px" /></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td colspan="3"><asp:Button ID="Button1" runat="server" Font-Size="9pt" OnClick="Button1_Click" Text="還原數(shù)據(jù)庫(kù)" /></td>
</tr>
</table>

2.后臺(tái)
復(fù)制代碼 代碼如下:

using System.Data.SqlClient;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string SqlStr1 = "Server=(local);DataBase=master;Uid=sa;Pwd=";
string SqlStr2 = "Exec sp_helpdb";
SqlConnection con = new SqlConnection(SqlStr1);
con.Open();
SqlCommand com = new SqlCommand(SqlStr2, con);
SqlDataReader dr = com.ExecuteReader();
this.DropDownList1.DataSource = dr;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataBind();
dr.Close();
con.Close();
}
}

protected void Button1_Click(object sender, EventArgs e)
{
string path = this.FileUpload1.PostedFile.FileName; //獲得備份路徑及數(shù)據(jù)庫(kù)名稱
string dbname = this.DropDownList1.SelectedValue;
string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";
string SqlStr2 = "use master restore database " + dbname + " from disk='" + path + "'";
SqlConnection con = new SqlConnection(SqlStr1);
con.Open();
try
{
SqlCommand com = new SqlCommand(SqlStr2, con);
com.ExecuteNonQuery();
Response.Write("<script language=javascript>alert('還原數(shù)據(jù)成功!');location='Default.aspx'</script>");
}
catch (Exception error)
{
Response.Write(error.Message);
Response.Write("<script language=javascript>alert('還原數(shù)據(jù)失??!')</script>");
}
finally
{
con.Close();
}
}
}

相關(guān)文章

  • 詳解使用DotNet CLI創(chuàng)建自定義的WPF項(xiàng)目模板

    詳解使用DotNet CLI創(chuàng)建自定義的WPF項(xiàng)目模板

    這篇文章主要介紹了詳解使用DotNet CLI創(chuàng)建自定義的WPF項(xiàng)目模板,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-04-04
  • 為HttpClient添加默認(rèn)請(qǐng)求報(bào)頭的四種解決方案

    為HttpClient添加默認(rèn)請(qǐng)求報(bào)頭的四種解決方案

    這篇文章主要給大家介紹了關(guān)于為HttpClient添加默認(rèn)請(qǐng)求報(bào)頭的四種解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用HttpClient具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • MVC+EasyUI+三層架構(gòu)簡(jiǎn)單權(quán)限管理系統(tǒng)

    MVC+EasyUI+三層架構(gòu)簡(jiǎn)單權(quán)限管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了MVC+EasyUI+三層架構(gòu)簡(jiǎn)單權(quán)限管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 正確使用dotnet-*工具的方法

    正確使用dotnet-*工具的方法

    這篇文章介紹了正確使用dotnet-*工具的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-12-12
  • asp.net?core集成ElasticSearch實(shí)現(xiàn)全文檢索功能

    asp.net?core集成ElasticSearch實(shí)現(xiàn)全文檢索功能

    索引是Elasticsearch中用于存儲(chǔ)文檔的容器,你可以使用Elasticsearch的REST?API、官方客戶端庫(kù)(如NEST)或Kibana等工具來(lái)創(chuàng)建和管理索引,本文給大家介紹asp.net?core集成ElasticSearch實(shí)現(xiàn)全文檢索功能,感興趣的朋友一起看看吧
    2024-08-08
  • ASP.NET配合jQuery解決跨域調(diào)用的問(wèn)題

    ASP.NET配合jQuery解決跨域調(diào)用的問(wèn)題

    這篇文章主要介紹了ASP.NET配合jQuery解決跨域調(diào)用的問(wèn)題,簡(jiǎn)單實(shí)用,需要的朋友可以參考下。
    2016-06-06
  • VS2013安裝提示必須安裝ie10的解決辦法

    VS2013安裝提示必須安裝ie10的解決辦法

    這篇文章主要為大家詳細(xì)介紹了VS2013安裝提示必須安裝ie10的解決辦法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • .NET Orm性能測(cè)試分析

    .NET Orm性能測(cè)試分析

    本篇文章給大家分享了.NET Orm性能測(cè)試的結(jié)果分析內(nèi)容,對(duì)此有需要的朋友可以參考學(xué)習(xí)下。
    2018-05-05
  • ASP.NET Core 3.0遷移的完美避坑指南

    ASP.NET Core 3.0遷移的完美避坑指南

    這篇文章主要給大家介紹了關(guān)于ASP.NET Core 3.0遷移的完美避坑指南,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用ASP.NET Core 3.0具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • .NET?Core類庫(kù)項(xiàng)目中讀取appsettings.json配置的方法

    .NET?Core類庫(kù)項(xiàng)目中讀取appsettings.json配置的方法

    ASP.NET?Core是一個(gè)全新的Web開發(fā)平臺(tái),微軟在它上面構(gòu)建了MVC、SingalR、GRPC、Orleans這樣廣泛使用的Web框架,今天通過(guò)本文給大家詳細(xì)介紹下.NET?Core讀取appsettings.json配置的方法,感興趣的朋友一起看看吧
    2022-03-03

最新評(píng)論

永仁县| 汤原县| 古蔺县| 萝北县| 达日县| 晋州市| 浑源县| 买车| 莲花县| 永泰县| 常州市| 固阳县| 河津市| 湟源县| 镇康县| 九龙县| 都安| 平罗县| 炎陵县| 山阴县| 会东县| 永春县| 房产| 正阳县| 怀来县| 会泽县| 余姚市| 哈密市| 博野县| 铅山县| 枣强县| 上栗县| 永川市| 宁城县| 芜湖市| 夹江县| 沧州市| 龙口市| 河南省| 北辰区| 石河子市|