3

谁能建议如何访问/读取脚本组件中的系统变量(例如,我想从脚本组件中的这个变量 System::PackageName 打包名称)

4

1 回答 1

11

在脚本任务编辑器中,在 ReadOnlyVariables 字段中提供要访问的变量名称(例如 System::PackageName)。

从脚本中,在 C# 示例中,使用以下命令:

public void Main()
    {
        bool fireAgain = true;

        // Read the variable
        String PackageName = (String)Dts.Variables["System::PackageName"].Value;

        // Post the value to progress results
        Dts.Events.FireInformation(3, "Package name:", PackageName, "", 0, ref fireAgain);

        Dts.TaskResult = (int)ScriptResults.Success;
    }

结果:

包名为包

于 2012-10-25T10:01:09.740 回答