Get SSIS package name with C#

一笑奈何 提交于 2021-01-28 05:44:21

问题


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();

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.

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


回答1:


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




回答2:


Extract your Integration Service Catalog to ispac. Open it with SSDT, and deploy to your new server. Much easier.



来源:https://stackoverflow.com/questions/46063382/get-ssis-package-name-with-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!