Access To Dts.Variables Causes Exception RRS feed

  • Question

  • Hey all...I'm pretty new to SSIS packages and things are coming along nicely.  My problem is accessing variables in script tasks.

    I've created two variables (package scope, strings, readonly = false)  - aDetailFiles and strDetailFile

    Within a Foreach Loop I loop through a folder.  I've added a script task and within that I try the following:

    Dts.Variables("User::aDetailFiles").Value = Dts.Variables("User:Tongue TiedtrDetailFile").Value.ToString() + "|" + Dts.Variables("User::aDetailFiles").Value.ToString()

    Everytime this script executes I get the following errors:

    at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
    at ScriptTask_feac87c947ce4431a4fee0ba0e13631d.ScriptMain.Main() in dts://Scripts/ScriptTask_feac87c947ce4431a4fee0ba0e13631d/ScriptMain:line 25

    I have searched this error message but the only thing I found was to set the ReadWrite variable property but I don't know where to set that.

    Expresion property set as false also.

    Any ideas?  Thanks.

    Thursday, August 23, 2007 11:00 PM


  • Right Click the script task, press F4, this will show the properties of the script task, there you will have properties called ReadOnlyVariables, ReadWriteVariables. You can set the variables name in this based on your requirement.
    These variables will be available in the script, else they dont have visibility inside the script task and an error will be thrown at run time.


    Thursday, August 23, 2007 11:15 PM