Sunday, March 26, 2006

SSIS 2005: Returning Values - To a Calling Package from a Child Package

There may be many ways to return values to a calling package from the child package. Today we are going to explore how to do that with the help of a script task from Calling Package.

A child package can be invoked from the calling package through a Script Task. In the following code snippet: A variable of the child package is being initialized and the child package is invoked. After execution of the child package - its variable "OutputVariable" is being read from the calling package.

Public Sub Main()

Dim pkg As String = "D:\SSISWork\Examples\ChildPackage.dtsx"

Dim app As Application = New Application()
Dim p As Package = app.LoadPackage(pkg, Nothing)

// Pass in a value to the Child Package
p.Variables("InputVariable").Value =

// Execute the Child Package
p.Execute()

// Read the Child Package Result Variable
MsgBox(p.Variables("OutputVariable").Value)

Dts.TaskResult = Dts.Results.Success
End Sub

0 Comments:

Post a Comment

<< Home