亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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)文章

  • Json返回時(shí)間的格式中出現(xiàn)亂碼問(wèn)題的兩種解決方案

    Json返回時(shí)間的格式中出現(xiàn)亂碼問(wèn)題的兩種解決方案

    使用Json返回?cái)?shù)據(jù)的時(shí)候時(shí)間的格式一般都會(huì)變了,變成我們不認(rèn)識(shí)的一些字符,那么當(dāng)我們遇到這些問(wèn)題的時(shí)候我們?cè)撛趺唇鉀Q呢,今天我就來(lái)小說(shuō)一下這個(gè)的解決方法
    2013-10-10
  • .NET Core類庫(kù)System.Reflection.DispatchProxy實(shí)現(xiàn)簡(jiǎn)易Aop的方法

    .NET Core類庫(kù)System.Reflection.DispatchProxy實(shí)現(xiàn)簡(jiǎn)易Aop的方法

    這篇文章主要給大家介紹了關(guān)于.NET Core類庫(kù)System.Reflection.DispatchProxy實(shí)現(xiàn)簡(jiǎn)易Aop的相關(guān)資料,文中通過(guò)示例代碼結(jié)束的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • asp.net iis 無(wú)法顯示網(wǎng)頁(yè)的解決方法分析

    asp.net iis 無(wú)法顯示網(wǎng)頁(yè)的解決方法分析

    使用過(guò)IIS的朋友都可能遇到過(guò)這樣的情況:即使您按照教科書的步驟做好各步設(shè)置以后,仍會(huì)出現(xiàn)“無(wú)法顯示網(wǎng)頁(yè)”的現(xiàn)象。
    2010-06-06
  • 淺談對(duì)Jquery+JSON+WebService的使用小結(jié)

    淺談對(duì)Jquery+JSON+WebService的使用小結(jié)

    本篇文章介紹了對(duì)Jquery+JSON+WebService的使用小結(jié)。需要的朋友參考下
    2013-04-04
  • Discuz!NT 3與asp.net 整合的實(shí)例教程

    Discuz!NT 3與asp.net 整合的實(shí)例教程

    本次整合只針對(duì)NETSNS中的代碼做了少許修改,完成了基本的和論壇同步注冊(cè),登陸和注銷,信息獲取,信息修改。為的是給各位Discuz!NT API愛(ài)好者做一個(gè)簡(jiǎn)單的API事例,供大家參考。
    2009-11-11
  • asp.net 2個(gè)日期之間的整月數(shù)的算法

    asp.net 2個(gè)日期之間的整月數(shù)的算法

    我是說(shuō)兩個(gè)日期之間間隔整月,比如2008-11-5 和 2009-4-3之間的整月,結(jié)果是12,1,2,3這四個(gè)月
    2009-06-06
  • Visual?Studio快捷鍵匯總

    Visual?Studio快捷鍵匯總

    這篇文章介紹了Visual?Studio的常用快捷鍵,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • ASP.NET MVC5網(wǎng)站開發(fā)添加文章(八)

    ASP.NET MVC5網(wǎng)站開發(fā)添加文章(八)

    小編整理的ASP.NET MVC5網(wǎng)站開發(fā)是一系列的文章體系,大家要一篇篇的仔細(xì)閱讀,今天這篇文章主要介紹了ASP.NET MVC5網(wǎng)站開發(fā)添加文章,需要的朋友可以參考下
    2015-09-09
  • c# 在WebBrowser中用SendMessage模擬鼠標(biāo)點(diǎn)擊

    c# 在WebBrowser中用SendMessage模擬鼠標(biāo)點(diǎn)擊

    想在WebBrowser控件里面模擬鼠標(biāo)點(diǎn)擊,在百度上找了半天,怎么也找不到,還是google強(qiáng)大,在一個(gè)國(guó)外網(wǎng)站上找到的,代碼比較清楚了,不做說(shuō)明。
    2010-02-02
  • .net core中Quartz的使用方法

    .net core中Quartz的使用方法

    這篇文章主要介紹了.net core中Quartz的使用方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-03-03

最新評(píng)論