NET复苏备份Sql

td style=width: 100px

{

tr

string returnMessage = string.Empty;

catch (Exception)

前台代码:

}

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

/table

try

else

html xmlns=

returnMessage = ex.Message;

/td

/// /summary

catch (Exception error)

/div

span style=font-size: 9pt; color: #ff3300/span

td colspan=3

asp:DropDownList ID=DropDownList2 runat=server Font-Size=9pt Width=124px

string path = databasefile;

SqlCommand com = new SqlCommand(SqlStr2, con);

/td

{

return;

{

RestoreDataBase(txtDbName.Text, path, ref returnMessage, true,con);

/td

using System.Web;

asp:TextBox ID=txtDbName runat=server/asp:TextBox

protected void Button1_Click(object sender, EventArgs e)

restoreSql += string.Format(use master exec killspid ‘{0}’;,
databasename);

td style=width: 100px

SqlCommand com = new SqlCommand(SqlStr2, con);

this.DropDownList1.DataTextField = name;

this.DropDownList1.DataBind();

try

td style=width: 100px; height: 21px

td style=width: 100px

asp:Button ID=Button2 runat=server Font-Size=9pt OnClick=Button2_Click
Text=还原数据库 /

{

td style=width: 100px; height: 21px

string SqlStr1 = Data Source=./sqlexpress;Initial Catalog=’ + dbName +
‘;Integrated Security=True;

/td

/td

finally

{

string SqlStr2 = backup database + dbName + to disk=’ +
this.TextBox1.Text.Trim() + .bak’;

try

{

asp:DropDownList ID=DropDownList1 runat=server Font-Size=9pt Width=124px

SqlDataReader dr = com.ExecuteReader();

/asp:DropDownList

{

}

}

{

/div

myCommand.Connection.Open();

SqlCommand com = new SqlCommand(SqlStr2, con);

/td

td style=width: 100px

/form

/body

span style=font-size: 9pt操 作 数 据 库/span

/// param name=errormessage苏醒数据库失利的音讯/param

{

success = false;

public bool RestoreDataBase(string databasename, string databasefile,
ref string returnMessage, bool forceRestore, SqlConnection conn)

SqlConnection con = new SqlConnection(SqlStr1);

}

/tr

this.DropDownList1.DataSource = dr;

td style=width: 100px

td

/td

}

tr

try

{

{

string dbName = string.Empty;

}

}

SqlConnection con = new SqlConnection(SqlStr1);

if (!IsPostBack)

con.Open();

}

Response.Write(error.Message);

dr.Close();

{

}

bool success = true;

/// summary

if (DropDownList1.Items.Count != 0)

/tr

Response.Write(returnMessage);

{

this.DropDownList1.DataSource = dr;

/// 苏醒数据库,可采用是还是不是足以逼迫恢复生机

if (DropDownList1.Items.Count != 0)

span style=font-size: 9pt操 作 数 据 库/span

{

myCommand.Parameters.Add(@dbname, SqlDbType.Char);

}

this.DropDownList1.DataTextField = name;

using System.Diagnostics;

con.Close();

}

string path = this.FileUpload1.PostedFile.FileName;
//得到备份路线及数据库名称

Response.Write(script
language=javascriptalert(‘还原数据战败!’卡塔尔国/script卡塔尔(قطر‎;

string SqlStr1 = Data Source=./sqlexpress;Initial Catalog=’ + dbName +
‘;Integrated Security=True;

table

string restoreSql = use master;;

/// param name=databasefile带还原的备份文件的通通路线/param

/td

con.Open();

using System.Data;

/head

}

td style=width: 100px

protected void Button2_Click(object sender, EventArgs e)

/td

title/title

} string SqlStr1 = Data Source=./sqlexpress;Initial Catalog=’ + dbName +
‘;Integrated Security=True;

asp:FileUpload ID=FileUpload1 runat=server Font-Size=9pt Width=190px /

using System.Data.SqlClient;

myCommand.Parameters[@dbname].Value = dbname;

returnMessage = 还原成功;

return success;

/td

com.ExecuteNonQuery();

form id=form1 runat=server

SqlCommand myCommand = new SqlCommand(restoreSql, conn);

catch (Exception error)

namespace SysSourceMgmt

using System.Web.UI;

/tr

myCommand.ExecuteNonQuery();

}

catch (Exception ex)

}

table

con.Close();

{

con = new SqlConnection(SqlStr1);

if (DropDownList1.Items.Count != 0)

dbName = txtDbName.Text.Trim();

using System.Web.UI.WebControls;

myCommand.Parameters.Add(@path, SqlDbType.Char);

tr

string path = this.FileUpload1.PostedFile.FileName;
//获得备份路线及数据库名称

tr

{

com.ExecuteNonQuery();

{

string dbname = databasename;

using System.Linq;

protected void Page_Load(object sender, EventArgs e)

else

if (forceRestore卡塔尔(英语:State of Qatar)//纵然强逼复苏

string dbName = string.Empty;

{

}

SqlStr1 = Server=(local);DataBase=master;Uid=sa;Pwd=;

dbName = DropDownList1.SelectedValue.Trim();

{

txtDbName.Text = SqlStr2;

SqlStr2 = Exec sp_helpdb;

/td

head runat=server

/td

Response.Write(script
language=javascriptalert(‘备份数据退步!’卡塔尔(英语:State of Qatar)/script卡塔尔(英语:State of Qatar);

td colspan=3

}

con.Open();

restoreSql += restore database @dbname from disk = @path;;

asp:Button ID=Button3 runat=server Font-Size=9pt OnClick=Button3_Click
Text=强逼复苏数据库 /

{

/td

protected void Button3_Click(object sender, EventArgs e)

using System;

}

}

/// param name=databasename待还原的数据库名称/param

asp:TextBox ID=TextBox1 runat=server Font-Size=9pt
Width=117px/asp:TextBox

dbName = txtDbName.Text.Trim();

myCommand.Parameters[@path].Value = path;

}

com = new SqlCommand(SqlStr2, con);

con.Close();

string SqlStr1 = Server=(local);DataBase=master;Uid=sa;Pwd=;

td

/// param name=forceRestore是还是不是强逼苏醒,借使为TRUE,则exec killspid
‘数据库名’ 停止此数据库的历程,那样能力还原数据库/param

string SqlStr2 = @use master restore database + dbName + from disk=’ +
path + ‘;

%@ Page Language=C# AutoEventWireup=true
CodeBehind=SqlDbMgmt.asp教程x.cs Inherits=SysSourceMgmt.SqlDbMgmt %

div style=width: 100%; height: 100px

/table

using System.Collections.Generic;

}

con.Open();

/// returns/returns

dbName = DropDownList1.SelectedValue.Trim();

body

{

SqlConnection con = new SqlConnection(SqlStr1);

if (File.Exists(this.TextBox1.Text.Trim()))

using System.IO;

/html 后台:

string dbName = string.Empty;

dbName = txtDbName.Text.Trim();

dr = com.ExecuteReader();

}

div

{

Response.Write(script
language=javascriptalert(‘备份数据成功!’卡塔尔国;’/script卡塔尔国;

string SqlStr2 = Exec sp_helpdb;

td style=width: 100px

finally

SqlConnection con = new SqlConnection(SqlStr1);

/tr

Response.Write(script
language=javascriptalert(‘还原数据成功!’卡塔尔;’/script卡塔尔国;

{

span style=font-size: 9pt备份名称和职务/span

public partial class SqlDbMgmt : System.Web.UI.Page

tr

}

}

}

Response.Write(error.Message);

dr.Close();

{

this.DropDownList1.DataBind();

}

tr

span style=font-size: 9pt操 作 数 据 库/span

asp:Button ID=Button1 runat=server Font-Size=9pt OnClick=Button1_Click
Text=备份数据库教程 /

{

myCommand.Connection.Close();

Response.Write(script
language=javascript教程alert(‘此文件已存在,请从新输入!’卡塔尔国;location=’Default.aspx’/script卡塔尔(قطر‎;

/td

/tr

td style=width: 100px

con.Close();

/asp:DropDownList

else

dbName = DropDownList1.SelectedValue.Trim();

/tr

finally

Response.Write(restoreSql);

{

网站地图xml地图