我有一个看起来像这样的 SSIS 包:
它通过命令行中的 Visual Studio 或 DTEXEC 运行良好。我已经部署了它,如下所示:
当我在 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 枚举器为空。For Each File 枚举器未找到任何与文件模式匹配的文件,或者指定的目录为空。
这对我来说没有意义,因为它都是从我的 PC 上运行的,我可以访问该目录,它通过命令行和 Visual Studio 运行良好。
环境
- MS SQL Server 2014 (v12.0.5546.0)
- MS Visual Studio 15(v14 更新 3)