在脚本任务的SSIS显示变量值 [英] SSIS display variable values in script task

查看:389
本文介绍了在脚本任务的SSIS显示变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一些测试,输出完整的结果从执行SQL任务设置成Foreach循环如下

I'm doing some testing, outputting a full result set from a Execute SQL Task into a Foreach loop as below

和我只是想我的输出变量值的消息框,然而,它似乎并没有工作。

and I just want to output my variable values to a message box, however it doesn't seem to work.

public void Main()
    {

        try
        {

            // TODO: Add your code here
            string Variables = Dts.Variables["User::ClientID"].ToString() +
            Dts.Variables["User::Passphrase"].ToString() +
            Dts.Variables["User::KeyFileName"].ToString() +
            Dts.Variables["User::InboundEncryptionRequired"].ToString() +
            Dts.Variables["User::SftpResponseRequired"].ToString() +
            Dts.Variables["User::OutboundDecryptionRequired"].ToString() +
            Dts.Variables["User::SftpHost"].ToString() +
            Dts.Variables["User::SftpPort"].ToString() +
            Dts.Variables["User::SftpUserName"].ToString() +
            Dts.Variables["User::Active"].ToString() +
            Dts.Variables["User::SftpDownloadFrom"].ToString() +
            Dts.Variables["User::SftpUploadTo"].ToString() +
            Dts.Variables["User::SftpDeleteFilesFromRemote"].ToString() +
            Dts.Variables["User::ConnectionProtocol"].ToString();

            MessageBox.Show(Variables);

        }



        catch (Exception Ex)
        {

            MessageBox.Show(Ex.Message);

        }
    }
}



}

}

我刚开始什么元素不能在集合中找到,尽管我知道查询输出2行。

I'm just getting "element cannot be found in a collection" or something, even though I know the query is outputting 2 rows.

我也映射在foreach循环我的变量,只有指定的阅读纸条任务变量。

I have also mapped my variables on the foreach loop and specified read only variables on scrip task.

* UPDATE *

这是我发疯。我三重检查我的变量名,可以确认我得到充分的结果集。

This is driving me nuts. I've triple checked my variable names, can confirm I'm getting full result set.

我删除了用户::从我的脚本任务的变量,但仍没有运气。

I removed the User:: from my script task variables, but still no luck.

推荐答案

听起来好像你的变量名的拼写不正确,它不能在数组中。

It sounds as if one of your variable names is not spelled correctly and it cannot be found in the array.

你也可以使用

string Variables = String.Format("{0},{1},...",Dts.Variables["User::ClientID"],Dts.Variables["User::Passphrase"],...)

显示值或设置变量的字符串。

to display the values or set your variables string.

这篇关于在脚本任务的SSIS显示变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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