實例如下:
//首先要添加 System.ServiceProcess.dll 引用 ServiceController sc = new ServiceController("MSSQLSERVER"); //判斷服務(wù)是否已經(jīng)關(guān)閉 if (sc.Status == ServiceControllerStatus.Stopped) { sc.Start(); MessageBox.Show("SQL數(shù)據(jù)庫服務(wù)啟動成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } //判斷服務(wù)是否已經(jīng)開啟 if (sc.Status != ServiceControllerStatus.Stopped) { sc.Stop(); MessageBox.Show("SQL數(shù)據(jù)庫服務(wù)成功關(guān)閉!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); }以上這篇C# 啟動 SQL Server 服務(wù)的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選