脚本任务中的对象变量
在我的包中,我有一个执行 Sql 任务,它将结果集设置为用户变量。然后,我有一个 ac# 脚本任务,需要引用此 User 变量作为结果集。我需要将整个结果集发送到我的脚本任务中,因为我调用的 Web 服务需要一次性获取整个结果集。
这是我正在测试的当前代码。这并不多,因为我仍在努力弄清楚该去哪里。
非常感谢任何对此的帮助
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;
}
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;
}
This is the update working code:
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
非常接近,要访问变量的值,您需要点击该属性
So very close, to access the
Value
of a variable, you need to hit that property