1

I have a SSIS Package that looks like this:

enter image description here

It runs fine via Visual Studio or DTEXEC in command line. I have deployed it, as seen here:

enter image description here

When I connect to and run it via C# in my WinForm it only seems to run the 'Truncate Table' task. I comes back and says it was Successful, but it only ran part of the package, which I DO NOT call Successful.

Here is the code I'm using to connect and run:

// Create a connection to the server
string sqlConnectionString = "Data Source=BSQL_01;Initial Catalog=master;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
MessageBox.Show("Created Connection");
// Create the Integration Services object
IntegrationServices integrationServices = new IntegrationServices(sqlConnection);

// Get the Integration Services catalog
Catalog catalog = integrationServices.Catalogs["SSISDB"];
MessageBox.Show("Created Catalog");

// Get the folder
CatalogFolder folder = catalog.Folders["PORGImport"];
MessageBox.Show("Created Folder");

// Get the project
ProjectInfo project = folder.Projects["PORGImport"];
MessageBox.Show("Created Project");

// Get the package
PackageInfo package = project.Packages["PORGImport.dtsx"];
MessageBox.Show("Created Package");

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

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");
    MessageBox.Show("Success");

} else if (executionOperation.Status == Operation.ServerOperationStatus.Failed) {
    Console.WriteLine("Failed");
    MessageBox.Show("Failed");

} else {
    Console.WriteLine("Something Went Really Wrong");
    MessageBox.Show("Oh Crap");
}

I looked in the package on the SQL Server and I see this error:

Purchase File Loop: Warning: The For Each File enumerator is empty. The For Each File enumerator did not find any files that matched the file pattern, or the specified directory was empty.

Which doesn't make sense to me since it's all running from my PC, I have access to the directory, it runs fine via command line and via Visual Studio.

Environment

  • MS SQL Server 2014 (v12.0.5546.0)
  • MS Visual Studio 15 (v14 Update 3)
Hadi
  • 36,233
  • 13
  • 65
  • 124
Dizzy49
  • 1,360
  • 24
  • 35
  • You might have access, but that didn't want mean the account that SQL Server is running under does. Also, are you saying that the SQL Server you're connecting to is running your your PC? – Thom A May 26 '19 at 06:52
  • This is related to this https://stackoverflow.com/questions/56303015/cant-connect-to-server-via-integrationservices – Nick.Mc May 26 '19 at 09:25
  • I already asked you in your other question: is the SQL Server running on the same machine as VS / command line? – Nick.Mc May 26 '19 at 09:26
  • No, the SQL Server is on another machine. I am using a UNC path for the folder location. – Dizzy49 May 26 '19 at 10:03
  • And does the account SQL Server is running under have access to your hard drive on your local PC? You still haven't answered that question. It shouldnt, in my opinion, and hence why it's not working. The files should be on a file server share, or locally on the SQL Server which the service account has access to, not on your PC. – Thom A May 26 '19 at 15:08

1 Answers1

0

Check that Variables values are assigned

From the screenshots, it looks like you are using expressions in the for each loop container since the fx mark is shown on the top left corner. Make sure you have assigned the variable before executing the packages.

Hadi
  • 36,233
  • 13
  • 65
  • 124
  • The folder path is a fixed variable in the SSIS package. It is a UNC path to the folder location. It is not a variable that is passed into the package at runtime. – Dizzy49 May 26 '19 at 10:04
  • @Dizzy49 check the variables value from the c# application. If they are correct then it is a permission issue – Hadi May 26 '19 at 10:34
  • @Dizzy49 https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-file-system-permissions-for-database-engine-access?view=sql-server-2017 – Hadi May 26 '19 at 18:37