Pass variables to child via C# script task?

谁说我不能喝 提交于 2019-12-13 21:22:28

问题


I don't want to use package configurations to pass variables from Parent to child package. I'd prefer to pass the variables to child, from a C# script task in the parent package. Can this be done ? Here is the pseudocode for what I hope to do -

//code in script task of parent package

Main(){

Object parentObj = SSIS.ParentPackage.myObject;

String parentStr =  SSIS.ParentPackage.myString;

callChildPackage(parentObj, parentStr);

}

回答1:


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



来源:https://stackoverflow.com/questions/20671920/pass-variables-to-child-via-c-sharp-script-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!