Dizzy49
Dizzy49

Reputation: 1520

"Parameter does not exist or you do not have sufficient permissions" when running SSIS package in C#

I have a SSIS package with a bunch of variables, listed below: enter image description here

I am trying to call the SSIS package from a C# Windows Form App using the code below:

// Create a connection to the server
string sqlConnectionString = "Data Source=BSQL_01;Initial Catalog=master;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);

// Create the Integration Services object
IntegrationServices integrationServices = new IntegrationServices(sqlConnection);

// Get the Integration Services catalog
Catalog catalog = integrationServices.Catalogs["SSISDB"];

// Get the folder
CatalogFolder folder = catalog.Folders["PORGPackages"];

// Get the project
ProjectInfo project = folder.Projects["PORGPackages"];

// Get the package
PackageInfo package = project.Packages["POHandler.dtsx"];

// Add project parameter
Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>();
executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "SessionID", ParameterValue = "636943168325507712" });

// Run the package
long executionIdentifier = package.Execute(false, null, executionParameter);

ExecutionOperation executionOperation = integrationServices.Catalogs["SSISDB"].Executions[executionIdentifier];

while (!executionOperation.Completed) {
    System.Threading.Thread.Sleep(5000);
    executionOperation.Refresh();
    MessageBox.Show("Running...");
}

if (executionOperation.Status == Operation.ServerOperationStatus.Success) {
    Console.WriteLine("Success");
} else if (executionOperation.Status == Operation.ServerOperationStatus.Failed) {
    Console.WriteLine("Failed");
} else {
    Console.WriteLine("Something Went Really Wrong");
}

I am getting the following error:

The parameter 'SessionID' does not exist or you do not have sufficient permissions.

Am I adding the parameter correctly? I don't know I can watch to see if it's being set, or if I have permission.

Upvotes: 2

Views: 4264

Answers (1)

Yahfoufi
Yahfoufi

Reputation: 2544

Am I adding the parameter correctly?

You have declared a variable called @SessionID not a parameter.

If you need to pass a variable value then you can refer to the following link:

For more information about both objects (variables & parameters) you can refer to the following articles:

Upvotes: 2

Related Questions