使用 C# 获取 SSIS 包名称 [英] Get SSIS package name with C#

查看:29
本文介绍了使用 C# 获取 SSIS 包名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 DTUTIL 在 C# 程序中将 SSIS 包从一个 SQL 服务器复制到另一个.包在 MSDB 中.

I'm copying SSIS packages from one SQL server to another in a C# program via DTUTIL. The packages are in MSDB.

string dtutilCmd = "/c DTUTIL /SOURCESERVER " + sourceServer + " /SQL " + myPackage + " /DestServer " + destServer + " /COPY " + myPackage;

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = dtutilCmd;
process.StartInfo = startInfo;
process.Start();

dtutilCmd 字符串中的变量都是字符串.问题是当我的用户输入包名称时,他们可能会弄错大小写.他们可能会编写 MYPACKAGE 以便将其部署为 MYPACKAGE,即使它实际上作为 MyPackage 存在于我想保留的源服务器上.

The variables in the dtutilCmd string are all strings. The issue is when my users input the package name they can get the case wrong. They might write MYPACKAGE so it gets deployed as MYPACKAGE, even if it actually exists as MyPackage on the source server, which I want to preserve.

所以我想以某种方式获取包名,并将其输入到我的 dtutilCmd 字符串的最后一部分.

So I want to somehow grab the package name, and feed it into the last part of my dtutilCmd string.

推荐答案

您需要做的就是利用 Microsoft.Dts.Runtime 命名空间的Application"类.然后使用它建立连接并从 MSDB 获取包信息.

All you need to do is make use of 'Application' class of Microsoft.Dts.Runtime namespace. You then establish a connection using that and get the packages info from the MSDB.

这是提供有关如何以编程方式执行此操作的更多详细信息的链接 - 以编程方式枚举可用包

Here is link that gives more details on how to go about doing it programatically - Enumerating Available Packages Programmatically

这篇关于使用 C# 获取 SSIS 包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆