Showing posts with label tasks. Show all posts
Showing posts with label tasks. Show all posts

Thursday, March 22, 2012

accessing components and task from scripting task

Hi, I have to researching of how to accesss package tasks and component using the SqlServer.Dts.Runtime class and so far, I havent found any solution. For example, if you package has a scriptiong task and a data flow task(<- which contains a data source component). Is it possible to use the scripting component to access the data source component in the data flow task and manipulate its properites like sqlcommand etc.

Emmanuel

An easier and more direct way to do this is to store the sqlcommand for the datasource in a package variable and set the variable value in the script task or even at the time of executing the package.

|||I know that can be done using variables and expressions and all that but i want to know where its possible to access component and dask of a package in a scripting task using a SqlServer.Runtime library. I know you can pass variable around be I want to know how to control component properties in a scripting task or component if possible. If anyone know how to do that or can direct me to the right resource, I will be glad. Thanks.|||Nope, the tasks and components can't directly access each other at runtime.

Tuesday, March 6, 2012

Access To Dts.Variables Causes Exception

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.

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.

Thanks