问题
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:
Use Parent-Child variable configurations
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)
Take over the execution of the child package entirely executing the package from inside your C# script task.
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