c# - 如何使用 C# 找出安装在 SQL Server 中的 SSIS?
问题描述
我正在使用 C# 编写一个 Windows 窗体应用程序。我用
ssisServer = new IntegrationServices(ssisConnection);
运行和使用 SSIS 包,但在运行包之前,我想确保用户在正确的系统中运行应用程序,并且 SQL Server 的 SQL Server 上有 SSIS。
如何在 C# 中查找服务器上是否安装了 SSIS?
解决方案
检查 SQL Server Integration Services 服务是否在您连接的服务器上运行。
SQL Server Service Name
SQL 2008 MsDtsServer100
SQL 2012 MsDtsServer110
SQL 2014 MsDtsServer120
SQL 2016 MsDtsServer130
SQL 2017 MsDtsServer140
SQL 2019 MsDtsServer150
服务的名称取决于您连接的 SQL Server 版本。例如,如果服务器是 SQL Server 2019,那么它将是 MsDtsServer150。您可以简单地检查服务是否存在并正在运行。
将 System.ServiceProcess 添加到您的项目引用中(它位于 .NET 选项卡上)。
using System.ServiceProcess;
ServiceController sc = new ServiceController("MsDtsServer150");
switch (sc.Status)
{
case ServiceControllerStatus.Running:
return "Running";
case ServiceControllerStatus.Stopped:
return "Stopped";
case ServiceControllerStatus.Paused:
return "Paused";
case ServiceControllerStatus.StopPending:
return "Stopping";
case ServiceControllerStatus.StartPending:
return "Starting";
default:
return "Status Changing";
}
推荐阅读
- javascript - Chrome 关闭时是否会触发事件?
- selenium - FileUtils 包中不存在 copyFile() 方法
- php - 如何在 PHPWord 中增加字符串首字母的高度
- c++ - 递归函数的内联
- linux - 如何在 Grafana 中获得确切的已用 RAM 百分比?
- javascript - 图表未显示对象的数据数组
- javascript - .modal() 函数在角度 8 中不起作用
- flutter - 在 Flutter 中检测 ExpansionTile 领先图标上的手势
- python - 为什么输出没有被删除'The'
- php - Ebay rest api 不适用于我的沙盒帐户