使用.cs代码执行SSIS

时间:2017-11-21 10:29:42

标签: c# ssis

请帮我解决这段代码。我正在尝试执行一个SSIS包,它从服务器获取数据然后转储到另一个服务器。当我手动运行包它工作正常,表更新。但是当我尝试使用.cs代码时,就会发生这种情况。请建议。以下是供参考的代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExecuteSSISPackage
{
    class Program
    {
        static void Main(string[] args)
        {
            ExecSSIS exec = new ExecSSIS();
            exec.execPackage();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Dts.Runtime;

namespace ExecuteSSISPackage
{
    public class ExecSSIS
    {
        public void execPackage()
        {
            String pkgLocation = @"C:\temp\Perfect_Order\Perfect_Order\Package.dtsx";
            Package ssispackage;
            Application app;
            DTSExecResult result;
          //  Variables vars;

            app = new Application();
            ssispackage = app.LoadPackage(pkgLocation, null);

            result = ssispackage.Execute();

            if (result == DTSExecResult.Success)
                Console.WriteLine("Success");
            else if (result == DTSExecResult.Failure)
                Console.WriteLine("Error");

        }
    }
}

0 个答案:

没有答案