c# - 在 C# .NET 中运行 SSIS 包

标签 c# sql-server ssis etl

我正在尝试从一个简单的控制台应用程序运行一个 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 HResult=0x80131513 Message=Method not found: 'Void Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'. Source=Microsoft.SqlServer.Management.IntegrationServices StackTrace: at Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices..ctor(SqlConnection sqlConnection) at SSIStutorial.Program.Main(String[] args) in C:\Users\kokoro\source\repos\SSIStutorial\Program.cs:line 26

最佳答案

我的控制台应用程序也有同样的问题。按照 Microsoft docs 上的所有步骤进行操作它没有工作,得到与你完全相同的错误找不到方法:'Void Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'.

Microsoft 文档解决方案不适用于控制台应用程序 (.NET Core),它仅适用于控制台应用程序 (.NET Framework)。

我猜您正尝试在控制台应用程序 (.NET Core) 上运行?我将我的更改为 .NET Framework,它运行良好。

关于c# - 在 C# .NET 中运行 SSIS 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65618658/

相关文章:

c# - 阅读来自 HttpWebResponse 的完整响应

sql-server - 如何在 SQL Server 中重置增量标识的起始值

sql - SSIS如何根据另一个用户变量的值动态选择用户变量

c# - 使用 CSS 内联更改 HTML 以使用数据 Url

c# - 静态助手类与实例类上的静态方法与扩展方法

sql - 在 sql server 存储过程中创建和循环列表

c# - 为什么 FireError 在 C# 2012 中失败,但在 VB 中有效,而 FireInformation 在两者中都有效?

sql-server - SSIS:请求的 OLE DB 提供程序 SQLNCLI10.1 未注册

c# - 如何在 XML 序列化后没有列表元素的包装器元素

sql - 我们可以在另一个 SP 中使用 Sql server profiler 获取存储过程调用吗