IntegrationServices仅运行SSIS包的一部分

时间:2019-05-26 05:23:09

标签: c# sql-server ssis ssis-2014

我有一个看起来像这样的SSIS包:

enter image description here

它可以通过Visual Studio或DTEXEC在命令行中正常运行。我已经部署了它,如下所示:

enter image description here

当我在WinForm中连接并通过C#运行它时,它似乎只运行了“截断表”任务。我回来说成功了,但是它只是包装的一部分,我不称它为成功。

这是我用来连接和运行的代码:

// 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");
}

我查看了SQL Server上的程序包,并看到此错误:

  

购买文件循环:警告:“每个文件”枚举器为空。   For Each File枚举器未找到与   文件模式,或者指定的目录为空。

对我来说这没有意义,因为它们全部在我的PC上运行,我可以访问目录,并且可以通过命令行和Visual Studio正常运行。

环境

  • MS SQL Server 2014(v12.0.5546.0)
  • MS Visual Studio 15(v14更新3)

1 个答案:

答案 0 :(得分:0)

检查是否已分配变量值

从屏幕快照中,您似乎在每个循环容器中使用表达式,因为fx标记显示在左上角。在执行软件包之前,请确保已分配了变量。