ActiveX script: parent assigning child global?

  • How is this done?

    I have a package with an activex script that calls a child package. How do I assign values to the child packages globals?

    Can the child reference the parents globals?

  • You can reference global variables in your ActiveX task a couple of ways. The first is to reference them through the DTSGlobalVariables collection such as:

    DTSGlobalVariables( "GV1" ).Value = myvalue

    You can also set up a reference to the child package itself using an (object) variable and then assign a value to the child package's global variable and execute the child package such as:

    Dim objPackage'package object variable

    Set objPackage = CreateObject("DTS.Package")

    'Note: the following line loads a package that is stored on the local server.

    'Different params for a package stored in repository.

    objPackage.LoadFromSQLServer "ServerNameHere","","","256",,,,"NameofChildPackageHere"

    objPackage.GlobalVariables.Item("childpackageglobalvariable").Value = somevaluehere

    objPackage.Execute ' Execute the package

    'Set object variable to nothing and free up resources

    objPackage.Uninitialize

    Set objPackage = Nothing

    hth,

    Michael

    Michael Weiss


    Michael Weiss

  • it was the...

    objPackage.GlobalVariables.Item("childpackageglobalvariable").Value = somevaluehere

    line I wanted

    thanks mhweiss

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply