Thursday, 29 August 2013

Passing user parameters to SSIS package

Passing user parameters to SSIS package

Here's my problem. I have a SSIS package that takes 1 parameter on input
called SegmentID. But I cant pass it from the c# code. I'm searching for2
days so far, and here's a solution I came up with, which should work, but
doesn't - SSIS package fails at the stage of getting parameter. What a
hell am I doing wrong?
using (SqlConnection con = GetConnection())
{
var integrationServices = new IntegrationServices(con);
if (integrationServices.Catalogs.Contains("SSISDB"))
{
var catalog = integrationServices.Catalogs["SSISDB"];
if (catalog.Folders.Contains("PSO"))
{
var folder = catalog.Folders["PSO"];
if (folder.Projects.Contains("PSO_SSIS"))
{
var project = folder.Projects["PSO_SSIS"];
project.Parameters["SegmentID"].Set(ParameterInfo.ParameterValueType.Literal,
segmentID);
if (project.Packages.Contains("Main.dtsx"))
{
var package = project.Packages["Main.dtsx"];
long executionIdentifier =
package.Execute(false, null);
return catalog.Executions[executionIdentifier];
}
}
}
}
}

No comments:

Post a Comment