mmi*_*mix 4 c# sql-server ssis .net-core .net-core-3.0
We are in the process of porting one WPF application to .net core and we sort of got stuck on SSIS portion. Previously we used Microsoft.SqlServer.Management.Sdk.Sfc and Microsoft.SqlServer.Smo to run SSIS using this code:
public void SSISUpload()
{
string targetServerName = "server";
string folderName = "Project1Folder";
string projectName = "Integration Services Project";
string packageName = "SSISPackage/Package.dtsx";
// Create a connection to the server
string sqlConnectionString = "Data Source=" + targetServerName +
";Initial Catalog=master;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
IntegrationServices integrationServices = new IntegrationServices(sqlConnection);
Catalog catalog = integrationServices.Catalogs["SSISDB"];
CatalogFolder folder = catalog.Folders[folderName];
ProjectInfo project = folder.Projects[projectName];
PackageInfo package = project.Packages[packageName];
// Run the package
package.Execute(false, null);
}
Run Code Online (Sandbox Code Playgroud)
However, the above references tie to .NET Framework and do not seem to have bindings for .net core or standard. We tried using Microsoft.SqlServer.SqlManagementObjects, which does have standard2.0 bindings, but that does not really translate 1-1 (classes are not there) and there does not seem to be any info online on how to achieve running SSIS from .net core/standard. Anyone managed to do this?
您可以使用不同的方法从C#.net core执行SSIS包:
除了使用之外, Microsoft.SqlServer.SqlManagementObjects您还可以简单地使用SQLCommand来执行SSIS包,例如:
Declare @execution_id bigint
EXEC [SSISDB].[catalog].[create_execution] @package_name=N'Package.dtsx',
@execution_id=@execution_id OUTPUT,
@folder_name=N'Deployed Projects',
@project_name=N'Integration Services Project1',
@use32bitruntime=False,
@reference_id=Null
EXEC [SSISDB].[catalog].[start_execution] @execution_id
GO
Run Code Online (Sandbox Code Playgroud)
您可以参考以下链接以获取更多信息:
另一种选择是使用Process.Start方法执行DTEXEC与SQL Server一起安装的应用程序。例如:
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"C:\Program Files\Microsoft SQL Server\130\DTS\Binn\DTExec.exe";
p.StartInfo.Arguments = "/ISServer \"\SSISDB\Project1Folder\Integration Services Project1\Package.dtsx\" /Server \"localhost\"";
p.Start();
Debug.WriteLine(p.StandardOutput.ReadToEnd());
p.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
有关更多信息,您可以参考以下链接:
| 归档时间: |
|
| 查看次数: |
384 次 |
| 最近记录: |