【发布时间】:2021-04-13 13:12:44
【问题描述】:
我正在尝试从一个简单的控制台应用程序运行 SSIS 包。不幸的是,我遇到了一些错误`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.IntegrationServices;
using System.Data.SqlClient;
namespace SSIStutorial
{
class Program
{
static void Main(string[] args)
{
// Variables
string targetServerName = "localhost";
string folderName = "Projects";
string projectName = "SSIS Tutorial";
string packageName = "Lesson 1.dtsx";
// Create a connection to the server
string sqlConnectionString = "Data Source = cgol1793109; Initial Catalog = TEST; Integrated Security=True;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
// Create the Integration Services object
IntegrationServices integrationServices = new IntegrationServices(sqlConnection);
// Get the Integration Services catalog
Catalog catalog = integrationServices.Catalogs["SSISDB"];
// Get the folder
CatalogFolder folder = catalog.Folders[folderName];
// Get the project
ProjectInfo project = folder.Projects[projectName];
// Get the package
PackageInfo package = project.Packages[packageName];
// Run the package
package.Execute(false, null);
}
}
}
在实例化 IntegrationServices 类型的 IntegrationServices 对象时,我得到以下信息。 我收到以下错误。
System.MissingMethodException H结果=0x80131513 消息=找不到方法:'无效 Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'。 源=Microsoft.SqlServer.Management.IntegrationServices 堆栈跟踪: 在 Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices..ctor(SqlConnection sqlConnection) 在 C:\Users\kokoro\source\repos\SSIStutorial\Program.cs:line 26 中的 SSIStutorial.Program.Main(String[] args) 处
【问题讨论】:
-
我没有看到在 doc 中采用连接字符串的构造函数重载
-
我传入的是 sqlConnection 对象而不是字符串
-
看起来大致正确。
cgol1793109上是否有SSISDB数据库?另一个观察结果是我通常在连接字符串中看到等号或分号周围没有空格,因此"Data Source=cgol1793109;Initial Catalog=TEST;Integrated Security=True;"
标签: c# sql-server ssis etl