Using variables in Script Component

  • Hello everyone,

    In the script task (control flow), variables can be used by just setting it readonly or readwrite and using the statement in the script task to assign a value to the variable like my example below:

    Dts.Variables("VariableName").Value = "Stuff"

    I am using a script component (data flow) to create my own data source. Looks like its working fine, but I can't figure out how to use variables in the script component task. The read only and read/write are there in the properties section of a script component, but when I type:

    dts.

    Intellisense doesn't fill in the rest, like it does if I do the same thing in a script task. Is it a different way to reference variables in a script component vs a script task?

    Thanks,

    Strick

  • Check the scope of the variable. To the best of my knowledge, only package variables will be available to every task. If you created it scoped in a task other than this one, you won't see it and intellisense won't either.

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • Use Variables. instead of DTS. when using variables in the Script Component.

    Have a look at this Books Online topic too: Comparing the Script Component and the Script Task.

  • When using a script component you need to enter the package variables you want to use in the custom properties section of the script screen. Then within the script you access the Variables using Variables.VariableName notation. You will have Intellisense after typing Variables. The variables you use do need to be in the scope of that task within the package.

    See the attached image.

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

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