Imports Microsoft.SqlServer.Dts.Runtime
Dim app As Application = New Application
Dim pack As Package = New Package
pack = app.LoadPackage("c:/test.dtsx", Nothing)
Dim var As Variables = pack.Variables
var("path").Value = "path"
var("msg2").Value = "msg"
var("type").Value = "type"
Dim result As DTSExecResult = pack.Execute(Nothing, var, Nothing, Nothing, Nothing)
If result = DTSExecResult.Success Then
Response.Write("success!")
Else
Response.Write("faile!")
End If
ASPX(C#)中调用SQLSERVER2005中的SSIS
文章出处:DIY部落(http://www.diybl.com/course/7_databases/sql/sqlServer/2008918/143278.html)
第一步:创建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);
文章出处:DIY部落( http://www.diybl.com/course/7_databases/sql/sqlServer/2008918/143278.html)