使用来自c#app

时间:2017-05-13 16:43:29

标签: c# ssis sql-server-2014 dts

我希望在标题中使用来自c#app的项目参数运行SSIS包(位于SSIS项目文件夹中)。 我在表达式中将ConnectionString设置为:@[$Project::OutputFilePath] +"report.csv"

我有这样的代码从c#windows console app运行包:

public static int ExecutePackage(string packageName)
{
    string pkgLocation = @"..\..\..\SSIS_Analyze_data_quality\" + packageName + ".dtsx";

    Package pkg;
    Application app;
    DTSExecResult pkgResults;

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

    pkgResults = pkg.Execute(); 

    if (pkgResults == DTSExecResult.Success)
    {
        Console.WriteLine("Package ran successfully");
        return 1;
    }
    else
    {
        Console.WriteLine("Package failed");
        return 0;
    }
}
// SSIS_Analyze_data_quality - this is the catalog with the SSIS project

但是当我运行此代码时,程序包将失败,因为它无法看到项目中的params。错误是:

"The variable \"$Project::OutputFilePath\" was not found in the Variables collection. The variable might not exist in the correct scope.\r\n"

所以我的问题是如何设置此参数的范围?让c#app看到项目参数,而不仅仅是包参数。

0 个答案:

没有答案