通过C#脚本任务将变量传递给子级? [英] Pass variables to child via C# script task?

查看:72
本文介绍了通过C#脚本任务将变量传递给子级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用程序包配置将变量从父程序包"传递到子程序包.我希望将变量从父程序包中的C#脚本任务传递给子程序.能做到吗?这是我希望做的伪代码-

 //父包脚本任务中的代码主要的(){对象parentObj = SSIS.ParentPackage.myObject;字符串parentStr = SSIS.ParentPackage.myString;callChildPackage(parentObj,parentStr);} 

解决方案

此答案是从MS论坛复制而来的.现在,谷歌是你的朋友.

为此,您有四个选择:

  1. 使用父子变量配置

  2. 在使用执行程序包任务"运行时,将值放在父程序包中的变量中,该变量可以从子程序包中引用.( http://agilebi.com/jwelch/2009/10/03/passing-an-object-from-a-parent-package-to-a-child )

  3. 接管子程序包的执行,完全从C#脚本任务内部执行该程序包.

  4. 使用类似任务工厂高级执行包"任务的方法.(完全公开:我为务实的作品工作)

第3项可能最接近您想要的内容.您需要使用Package.Execute方法自己运行子包.这样做的好处是您可以在执行程序包之前显式设置子程序包变量.

约翰·韦尔奇|www.pragmaticworks.com |www.agilebi.com |ssisUnit.codeplex.com

链接- 解决方案

This answer is copied from MS forum. Now, google is your friend.

You have four choices for this:

  1. Use Parent-Child variable configurations

  2. Place the value in a variable in the parent package, which can be referenced from the child package, when run with an Execute Package Task. (http://agilebi.com/jwelch/2009/10/03/passing-an-object-from-a-parent-package-to-a-child)

  3. Take over the execution of the child package entirely executing the package from inside your C# script task.

  4. Use something like the Task Factory Advanced Execute Package task. (Full Disclosure: I work for Pragmatic Works)

Item 3 is probably closest to what you want. You'd need to use the Package.Execute method to run the child package yourself. The advantage of doing that is you can set child package variables explicitly before executing the package.

John Welch | www.pragmaticworks.com | www.agilebi.com | ssisUnit.codeplex.com

Link - http://social.msdn.microsoft.com/Forums/sqlserver/en-US/450ec296-71bb-4170-a71c-a4e3bf453bab/pass-variables-to-child-via-c-script-task-?forum=sqlintegrationservices#450ec296-71bb-4170-a71c-a4e3bf453bab

这篇关于通过C#脚本任务将变量传递给子级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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