在ssis脚本组件中的Foreach循环 [英] Foreach loop in ssis script component

查看:70
本文介绍了在ssis脚本组件中的Foreach循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ssis数据流的脚本组件中有以下代码。 PartNo将被传递为:

ABC

DEF

GHI



如何将它们连接成一个字符串,如ABC,DEF,GHI?

我编写了如下脚本之后,它会提示我一条错误信息

下面是我的剧本:



Hi, I have the following codes in script component in ssis data flow. "PartNo" will be passed in as:
ABC
DEF
GHI

How can I concatenate them into one string like ABC,DEF,GHI?
After I have written my script as below, it prompts me an error message
Below are my script:

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    string PartNo = Row.PartNo;
    foreach (string partNumber in Row.PartNo)
    {
        Output0Buffer.AddRow();
        Output0Buffer.PartNoAll = PartNo;
    }
}







如果我删除了foreach循环,那么没有错误,但输出不是我想要的。

任何帮助将不胜感激。谢谢。




If I remove the foreach loop, there is no error but the output is not as I desired.
Any help would be appreciated. Thank you.

推荐答案

最简单的方法是这样的:



The easiest way is like this:

string result = string.Join(",",Row.PartNo)





假设该行.PartNo是一个可枚举的



That is assuming that Row.PartNo is an enumerable


这篇关于在ssis脚本组件中的Foreach循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆