如何找到使用C#在SQL Server中安装的SSI?

如何找到使用C#在SQL Server中安装的SSI?,c#,sql-server,ssis,C#,Sql Server,Ssis,我正在用C#编写一个Windows窗体应用程序。我用 要运行和使用SSIS包,但在运行包之前,我希望确保用户在正确的系统中运行应用程序,并且SQL Server的SQL Server上有SSIS 如何在C#中查找服务器上是否安装了SSIS?检查您连接到的服务器上是否正在运行SQL server Integration Services服务 SQL Server Service Name SQL 2008 MsDtsServer100 SQL 2012

我正在用C#编写一个Windows窗体应用程序。我用

要运行和使用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选项卡上)


您可以检查服务器上是否存在SSIDB?是的,我认为这是一个很好的解决方案
SQL Server        Service Name
SQL 2008          MsDtsServer100
SQL 2012          MsDtsServer110
SQL 2014          MsDtsServer120
SQL 2016          MsDtsServer130
SQL 2017          MsDtsServer140
SQL 2019          MsDtsServer150
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";
}