Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Reference Package Properties in Script Task

Author  Topic 

ddamico
Yak Posting Veteran

76 Posts

Posted - 2012-06-09 : 22:18:26
Good day.

I am working on a script task that will log the name of the configuration file used by the package. I understand how to how to use the Configurations class. My big hurdle is how do I reference the parent package so i can get Package.Configurations?

The sample code i found online was showing how to create a new package and create the configurations. I was unable to find example of how to reference the parent package.

Any assistance would be appreciated.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-09 : 22:37:26
you need to use configuration type of parent package variable to access properties from parent package
see
http://microsoft-ssis.blogspot.com/2011/06/passing-variables-from-parent-package.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ddamico
Yak Posting Veteran

76 Posts

Posted - 2012-06-10 : 08:05:40
Thanks for the information, looks great. However, the next question is how to expose the

Parent.Configurations (object). I don't see it listed anywhere. The goal is to log the name of the XML file containing the properties. I am not seeing that as an option.

Any help with that would be appreciated. Thanks in advance
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-10 : 14:39:38
quote:
Originally posted by ddamico

Thanks for the information, looks great. However, the next question is how to expose the

Parent.Configurations (object). I don't see it listed anywhere. The goal is to log the name of the XML file containing the properties. I am not seeing that as an option.

Any help with that would be appreciated. Thanks in advance



why not add the filename also as value of variable in parent package and then pass that variable value to child using parent package configuration type.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ddamico
Yak Posting Veteran

76 Posts

Posted - 2012-06-11 : 12:01:50
So, we have multiple configurations files being used. The goal is to log the path of each just to ensure that the right files are being used during run time in case someone package has been changed is referencing another configuration file other than what we expect.

From what I am seeing there is no way to reference the object Package.Configurations within the a script task for the current package. At least it isn't clear by looking at examples how i can reference the current packages values.

I may be missing that. I would like to setup a variable that holds the package properties and then within the script task assign cfgs to Package.Configurations to get the collection and loop through logging the path to each config file.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-11 : 16:53:56
sorry i'm not understanding your full scenario. where do you get values from? are value are configurations themselves or values stored within configuration properties? Also whats the issue you're facing when trying to pass parents package config values through variable created inside and passed on to child using pacrent package variable configuration type?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ddamico
Yak Posting Veteran

76 Posts

Posted - 2012-06-12 : 10:54:54
visakh16,

The scenario is we have two configuration files per package

1. common.dtsconfig - this contains common variables used by all
packages (i.e. SqlConn)
2. <package>dtsconfig - this contains flags for enabling/disabling
external tools as necessary for specific package
(i.e. EnableScrubber)

The goal at runtime is to have a script task within the package (vb or c#) that I can use the DTS.Log command and log the name of each of the configuration files.

I know one of the properties of the package is Configurations (collection). I found articles on how to create a new package and new configuration not in SSIS but the .Net app.

The issue that I am facing is how to reference the current package.configurations in the script task. I am hoping this is possible but I haven't been able to find an example out there that does that. My goal would be to loop through the configurations one at a time and log Configuration.

As an example we might do something like this

DTS.LOG(Configuration.ConfigurationString). Hope this gives a bit of a clearer picture. thanks again.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-17 : 12:51:22
is the config path currently hardcoded or is it stored inside environment variable (indirect) ?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -