如何分配在脚本任务组件中设置的变量? [英] How to assign variable that is getting set within script task component?
问题描述
您好,
我有一个下面的-script组件,是否可以使用FileName变量,构建表达式并在文件连接管理器中使用它?
我在这条路径上有多个文件,我想读取每个文件并将其传递给下一个组件。
是否可以中断循环并传递Filename来执行数据流程任务组件,完成后,我想回到脚本组件读取下一个文件并运行另一个数据任务组件。
                      
FileInfo fileinfo;
          string [] files = Directory.GetFiles(Dts.Variables [" User :: folderpath"]。Value.ToString()); foreach(文件中的字符串文件)
          {
              //阅读变量
              string PackageName =(string)Dts.Variables [" System :: PackageName"]。Value;
              string FileName = Path.GetFileName(file);
                  Dts.Variables [" User :: FileName"]。Value = FileName;
                  Dts.TaskResult =(int)ScriptResults.Success;
                 休息;
              }
chipsy
使用ForEach文件对象。
参见:
https://docs.microsoft.com/en-us/ SQL /集成的服务/控制流/的foreach - 环 - 容器?视图= SQL服务器-2017
Hello,
I have a below -script component,Is it possible to use FileName variable ,build expression and use it in File connection manager?
I have multiple files at this path,I want to read each file and pass it to next component.
Is it possible to break loop and pass Filename to execute data flow task component,when this finish,I want to go back to script component read next file and run another data task component.
FileInfo fileinfo;
string[] files = Directory.GetFiles(Dts.Variables["User::folderpath"].Value.ToString());foreach (string file in files)
{
// Read the variable
string PackageName = (string)Dts.Variables["System::PackageName"].Value;
string FileName = Path.GetFileName(file);
Dts.Variables["User::FileName"].Value = FileName;
Dts.TaskResult = (int)ScriptResults.Success;
break;
}
chipsy
Use ForEach file object.
See:
这篇关于如何分配在脚本任务组件中设置的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!