C# 启动 SQL Server 服务的实例
发布时间:2020-12-15 05:46:21 所属栏目:百科 来源:网络整理
导读:实例如下: //首先要添加 System.ServiceProcess.dll 引用 ServiceController sc = new ServiceController("MSSQLSERVER"); //判断服务是否已经关闭 if (sc.Status == ServiceControllerStatus.Stopped) { sc.Start(); MessageBox.Show("SQL数据库服务启动成
实例如下: //首先要添加 System.ServiceProcess.dll 引用 ServiceController sc = new ServiceController("MSSQLSERVER"); //判断服务是否已经关闭 if (sc.Status == ServiceControllerStatus.Stopped) { sc.Start(); MessageBox.Show("SQL数据库服务启动成功!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information); } //判断服务是否已经开启 if (sc.Status != ServiceControllerStatus.Stopped) { sc.Stop(); MessageBox.Show("SQL数据库服务成功关闭!",MessageBoxIcon.Information); } 以上这篇C# 启动 SQL Server 服务的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程小技巧。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |