Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IntegrationServices仅运行SSIS包的一部分_C#_Sql Server_Ssis_Ssis 2014 - Fatal编程技术网

C# IntegrationServices仅运行SSIS包的一部分

C# IntegrationServices仅运行SSIS包的一部分,c#,sql-server,ssis,ssis-2014,C#,Sql Server,Ssis,Ssis 2014,我有一个SSIS包,看起来像这样: 它通过命令行中的VisualStudio或DTEXEC运行良好。我已经部署了它,如下所示: 在WinForm中,当我连接到并通过C#运行它时,它似乎只运行“Truncate Table”任务。我回来说它成功了,但它只运行了包的一部分,我不称之为成功 以下是我用来连接和运行的代码: // Create a connection to the server string sqlConnectionString = "Data Source=BSQL_01;In

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

它通过命令行中的VisualStudio或DTEXEC运行良好。我已经部署了它,如下所示:

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

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

// 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枚举数为空。 For Each文件枚举器未找到任何与 文件模式,或指定的目录为空

这对我来说没有意义,因为它都是从我的PC上运行的,我可以访问目录,它可以通过命令行和Visual Studio正常运行

环境

  • MS SQL Server 2014(v12.0.5546.0)
  • MS Visual Studio 15(v14更新3)
检查是否分配了变量值 从屏幕截图上看,您似乎在for each循环容器中使用表达式,因为
fx
标记显示在左上角。确保在执行包之前已分配变量

检查是否分配了变量值 从屏幕截图上看,您似乎在for each循环容器中使用表达式,因为
fx
标记显示在左上角。确保在执行包之前已分配变量


您可能具有访问权限,但这并不意味着运行SQL Server的帐户具有访问权限。另外,您是说您连接的SQL Server正在运行您的PC吗?这与此有关。我已经在您的另一个问题中问过您:SQL Server是否与VS/命令行在同一台机器上运行?不,SQL Server在另一台机器上。我正在使用UNC路径作为文件夹位置。运行SQL Server的帐户是否可以访问本地电脑上的硬盘?你还没有回答那个问题。在我看来,它不应该这样做,因此它不起作用。这些文件应位于文件服务器共享上,或位于服务帐户有权访问的SQL server上,而不是在您的电脑上。您可能有权访问,但这并不意味着运行SQL server的帐户有权访问。另外,您是说您连接的SQL Server正在运行您的PC吗?这与此有关。我已经在您的另一个问题中问过您:SQL Server是否与VS/命令行在同一台机器上运行?不,SQL Server在另一台机器上。我正在使用UNC路径作为文件夹位置。运行SQL Server的帐户是否可以访问本地电脑上的硬盘?你还没有回答那个问题。在我看来,它不应该这样做,因此它不起作用。文件应位于文件服务器共享上,或位于服务帐户有权访问的SQL server本地,而不是您的PC上。文件夹路径是SSIS包中的固定变量。它是指向文件夹位置的UNC路径。它不是在运行时传递到包中的变量。@Dizzy49检查c#应用程序中的变量值。如果他们是正确的,那么这是一种许可issue@Dizzy49文件夹路径是SSIS包中的固定变量。它是指向文件夹位置的UNC路径。它不是在运行时传递到包中的变量。@Dizzy49检查c#应用程序中的变量值。如果他们是正确的,那么这是一种许可issue@Dizzy49