第一步:创建SSIS
打开VS2005,创建商业智能项目---Integration Services项目(需在安装sqlserver2005时,选择安装Integration Service服务)
第二步:在程序中引用 Microsoft.SQLServer.ManageDTS
第三步:
private void Excutepackage(string path)
{
//新建dts执行程序
dts.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
//新建一个包
dts.Package pack = new Microsoft.SqlServer.Dts.Runtime.Package();
//加载一个存在的包
pack = app.LoadPackage(path, null);
//给变量赋值
pack.Variables["CreateTime"].Value = TextBox_date.Text;
pack.Variables["BackFilePath"].Value = Server.MapPath("") + "//DataBackUp//Filing_BackUp_" + System.DateTime.Now.ToString("yyyyHHdd_HHmmss") + ".bak";
//执行包
dts.DTSExecResult result = pack.Execute();
if (result.Equals(dts.DTSExecResult.Success))
{
TextBox_Resoult.Text = "备份成功" + System.DateTime.Now.ToString();
}
else
{
TextBox_Resoult.Text = "备份失败" + System.DateTime.Now.ToString();
}
}
第四步:调用
string DTS_PATH = Server.MapPath("") + "//DTS//Package.dtsx";
Excutepackage(DTS_PATH);
打开VS2005,创建商业智能项目---Integration Services项目(需在安装sqlserver2005时,选择安装Integration Service服务)
第二步:在程序中引用 Microsoft.SQLServer.ManageDTS
第三步:
private void Excutepackage(string path)
{
//新建dts执行程序
dts.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
//新建一个包
dts.Package pack = new Microsoft.SqlServer.Dts.Runtime.Package();
//加载一个存在的包
pack = app.LoadPackage(path, null);
//给变量赋值
pack.Variables["CreateTime"].Value = TextBox_date.Text;
pack.Variables["BackFilePath"].Value = Server.MapPath("") + "//DataBackUp//Filing_BackUp_" + System.DateTime.Now.ToString("yyyyHHdd_HHmmss") + ".bak";
//执行包
dts.DTSExecResult result = pack.Execute();
if (result.Equals(dts.DTSExecResult.Success))
{
TextBox_Resoult.Text = "备份成功" + System.DateTime.Now.ToString();
}
else
{
TextBox_Resoult.Text = "备份失败" + System.DateTime.Now.ToString();
}
}
第四步:调用
string DTS_PATH = Server.MapPath("") + "//DTS//Package.dtsx";
Excutepackage(DTS_PATH);