I've been looking around the web for days
now and I haven't been able to find a single example on how to pass environment variables to a package.
We're using the new ssis project development to deploy packages to the SSIS catalog so I need to use the Microsoft.SQLServer.Management.IntegrationServices
assembly to access packages. I found an excelent example on how to run it here
. The problem is, every one of our packages (more than 100) have around 7 parameters they need to execute and I can't provide values for them
! Not even hard-coded values. It's driving me insane. I keep getting the Reference not made to an instance of an object
error because apparently the PackageInfo
class is static. For this project, there are different environments configured in the SSIS Catalog that I need to map to the variables of the packages.
I've tried setting the parameters like they set the
parameter on the example, but to no effect. For some variables I get an error saying that I don't have sufficient permissions to access them, which makes sense but I can't figure out how (or where) to provide the needed credentials (It might be good to mention that we've used windows authentication until now, configuring permissions to the domain users that are working on the project).
I am stuck. Has anybody done this? I know its really easy to set the variables the old way (Dts.Runtime assembly) but this new assembly is poorly documented and very few examples are available on the web (none of which touch the subject of environment variables). Any help would be gratefully accepted!
This is the code I'm using:
SqlConnection connection = new SqlConnection(@"Data Source=my-ssis-server;Initial Catalog=MyDB;Integrated Security=SSPI;");
IntegrationServices ssis = new IntegrationServices(connection);
PackageInfo pk = ssis.Catalogs["SSISDB"].Folders["MyFolder"].Projects["MyProject"].Packages["MyPackage.dtsx"];
var executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>();
ObjectType = 50,
ParameterName = "SYNCHRONIZED",
ParameterValue = 1
long executionIdentifier = pk.Execute(false, null, executionParameter);