Kin*_*oro 6 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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在实例化 IntegrationServices 类型的 IntegrationServices 对象时,我得到以下信息。我收到以下错误。
System.MissingMethodException HResult=0x80131513 Message=未找到方法:“无效 Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)”。源 = Microsoft.SqlServer.Management.IntegrationServices StackTrace:位于 C:\Users\kokoro\source\ 中的 SSIStutorial.Program.Main(String[] args) 处的 Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices..ctor(SqlConnection sqlConnection) repos\SSIStutorial\Program.cs:第 26 行
参考官方文档,您用于定义连接和实例化 IntegrationServices 对象的步骤是正确的。这意味着问题是由连接字符串引起的。尝试删除额外的空格,编辑 Integrated security 参数,并使用 master 数据库作为初始目录:
string sqlConnectionString = "Data Source=cgol1793109;Initial Catalog=master;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1786 次 |
| 最近记录: |