重新创建一个程序来运行ssis包.得到一个LoadPackage错误

本文关键字:一个 LoadPackage 错误 ssis 运行 新创建 程序 创建 | 更新日期: 2023-09-27 18:13:28

using System;
using System.Windows.Forms;
using Microsoft.SqlServer.Dts.Runtime;
using Application = System.Windows.Forms.Application;
    private void Execute_Package()
    {
        string pkgLocation = @"c:'test.dtsx";
        Package pkg;
        Application app;
        DTSExecResult pkgResults;
        Variables vars;
        app = new Application();
        pkg = app.LoadPackage(pkgLocation, null);
        vars = pkg.Variables;
        vars["A_Variable"].Value = "Some value";
        pkgResults = pkg.Execute(null, vars, null, null, null);
        if (pkgResults == DTSExecResult.Success)
            Console.WriteLine("Package ran successfully");
        else
            Console.WriteLine("Package failed");
    }
 pkg = app.LoadPackage(pkgLocation, null);  <-- LoadPackage error

我把这个例子复制到vs2013中添加了参考,我在LoadPackage行上得到了一个错误:

 does not contain a definition for 'LoadPackage' and no extension
 method 'LoadPackage' accepting a first argument of type
 'System.Windows.Forms.Application' could be found (are you missing a
 using directive or an assembly reference?

还有别的参考文献需要我添加吗?我在谷歌上搜索,但没有找到。也许我只是累了。请帮助。

重新创建一个程序来运行ssis包.得到一个LoadPackage错误

变化:

using Microsoft.SqlServer.Dts.Runtime;
using Application = System.Windows.Forms.Application;

:

using Microsoft.SqlServer.Dts.Runtime;
using Application = Microsoft.SqlServer.Dts.Runtime.Application;

您是否尝试过从代码中运行DTEXEC实用程序?我一直都是这样。

对不起,我不能提供一个例子,目前我在移动设备上。

问题是我用错了using语句

我正在使用using Application = System.Windows.Forms.Application;我应该使用using Application = Microsoft.SqlServer.Dts.Runtime.Application

一个工作的朋友发现了这个问题

相关文章: