首页 > 解决方案 > 无法通过 IntegrationServices 连接到服务器

问题描述

我正在尝试连接到我的 SQL Server 以运行 SSIS 包。我承认这是我第一次尝试这个,所以我并不完全相信我的一切都是正确的。

我在该行收到“无法连接到服务器 BSQL_01”的一般错误:

IntegrationServices ssisServer = new IntegrationServices(ssisConnection);

这是我的 SQL Server,唯一的包是我要运行的包:

在此处输入图像描述

这是我遇到问题的代码。

// Connection to the database server where the packages are located
SqlConnection ssisConnection = new SqlConnection("Data Source=BSQL_01;Initial Catalog=master;Integrated Security=SSPI;");

// SSIS server object with connection
IntegrationServices ssisServer = new IntegrationServices(ssisConnection);

// The reference to the package which you want to execute
PackageInfo ssisPackage = ssisServer.Catalogs["SSISDB"].Folders["PORGImport"].Projects["PORGImport"].Packages["PORGImport.dtsx"];

long executionIdentifier = ssisPackage.Execute(false, null, executionParameter);

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

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

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

更新

好的,我将我的 ConnectionString 中的初始目录更改为“Mmaster”,我不再收到错误消息。它似乎在我获得“成功”时运行,但是,当我检查应该填充的表时,什么都没有。

标签: c#sql-serverwinformsssis

解决方案


ConnectionString 的“初始目录”需要是“主”,而不是“SSISDB”

SqlConnection ssisConnection = new SqlConnection("Data Source=BSQL_01;Initial Catalog=master;Integrated Security=SSPI;");

推荐阅读