使用C#调用SSIS包

来源:互联网 发布:赢顺期货软件 编辑:程序博客网 时间:2024/06/05 16:39

使用带参数的包,首先引入
using Microsoft.SqlServer.Dts.Runtime;

然后在程序中为包变量赋值,具体方法代码:


private void runetl()        {            Console.WriteLine("ETL start...");            string filepath = installedPath + "\\etl\\Package.dtsx";            Microsoft.SqlServer.Dts.Runtime.Application application = new Microsoft.SqlServer.Dts.Runtime.Application();            Package package = application.LoadPackage(filepath, null, true);            package.Variables["dbservername"].Value = dwservername;            package.Variables["dbname"].Value = dwdbname;            package.Variables["varFolderName"].Value = thispath;            DTSExecResult result = package.Execute();            if (result.Equals(DTSExecResult.Success))                listBox1.Items.Add("ETL success");            else            {                listBox1.Items.Add("ETL failed");                return;            }        } 


0 0
原创粉丝点击