脚本任务中的对象变量 [英] Object Variable in script tasks

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

问题描述

在我的包中,我有一个执行 Sql 任务,它将结果集设置为用户变量.然后我有一个 c# 脚本任务,需要将此 User 变量作为结果集引用.我需要将整个结果集发送到我的脚本任务中,因为我调用的 Web 服务需要一次性获得整个结果集.

In my package, I have an Execute Sql Task that sets the result set to a User variable. I then have a c# script task that needs to reference this User variable as a result set. I need the entire result set sent into my script tasks as the web service I am calling needs the entire result set in one shot.

这是我正在测试的当前代码.这并不多,因为我仍在试图弄清楚该去哪里.

This is the current code I am testing with. It isn't much as I am still trying to figure out where to go with it.

非常感谢您对此的任何帮助

Any help with this is greatly appreciated

public void Main()
{
    Variable resultSet = Dts.Variables["User::ZBatch_Order_Export_ResultSet"];

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

这是更新工作代码:

public void Main()
{
    DataTable dt = new DataTable();
    OleDbDataAdapter oleDa = new OleDbDataAdapter();

    oleDa.Fill(dt, Dts.Variables["User::ZBatch_Order_Export_ResultSet"].Value);

    foreach (DataRow row in dt.Rows)
    {
        Dts.Events
           .FireError(0, "ZBatch - Script Task", row["orderDate"]
           .ToString(), String.Empty, 0);
        // Do some Webservice magic
    }

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

推荐答案

非常接近,要访问变量的Value,您需要点击该属性

So very close, to access the Value of a variable, you need to hit that property

public void Main()
{
    Variable resultSet = Dts.Variables["User::ZBatch_Order_Export_ResultSet"].Value;

    // do stuff here with resultSet and the webservice

    Dts.TaskResult = (int)ScriptResults.Success;


}

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

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