Skip to content

Instantly share code, notes, and snippets.

@joymon
Last active August 29, 2015 14:25
Show Gist options
  • Save joymon/12cb4a537b94fb18c119 to your computer and use it in GitHub Desktop.
Save joymon/12cb4a537b94fb18c119 to your computer and use it in GitHub Desktop.
Invoke SSIS With Parameters & Variables set
internal void TestExecutionInstanceId()
{
Package pkg = GetPackageFromConstantLocationWithParametersSet();
DTSExecResult pkgResults = pkg.Execute();
object executionIdAsObj = pkg.Variables["System::ExecutionInstanceGUID"].Value;
Guid executionId = Guid.Parse(executionIdAsObj.ToString());
Console.WriteLine(pkgResults.ToString());
}
private static Package GetPackageFromConstantLocationWithParametersSet()
{
string pkgLocation = @"..\Package.dtsx"; //Location to dtsx package
Package pkg = GetLoadedPackageWithParametersSet(pkgLocation);
return pkg;
}
private static Package GetLoadedPackageWithParametersSet(string pkgLocation)
{
Application app = new Application();
Package pkg = app.LoadPackage(pkgLocation, null);
AddParametersIntoPackage(pkg);
return pkg;
}
private static void AddParametersIntoPackage(Package pkg)
{
pkg.Parameters["number"].Value = 3;
pkg.Variables["counter"].Value = 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment