zoukankan
html css js c++ java
[原]C#开启停止SqlServer服务
using
System.Diagnostics;
using
System.ServiceProcess;
/**/
///
<summary>
///
程序载入时的状态,Author:Kennytian@msn.com
///
</summary>
private
void
LoatStatus()
{
ServiceController sc
=
new
ServiceController(
"
MSSQLSERVER
"
);
string
status
=
sc.Status.ToString();
sc.Close();
label1.Text
=
"
Current status is:
"
+
status;
if
(status.Equals(
"
Running
"
))
StartSql.Text
=
"
Stop
"
;
else
StartSql.Text
=
"
Start
"
;
}
/**/
///
<summary>
///
开启停止SqlServer服务,Author:Kennytian@msn.com
///
</summary>
///
<param name="text">
按钮上的字
</param>
private
void
StartOrStopSqlServerService(
string
text)
{
ServiceController sc
=
new
ServiceController(
"
MSSQLSERVER
"
);
bool
startText
=
text.Equals(
"
Start
"
);
bool
stopText
=
text.Equals(
"
Stop
"
);
bool
Runned
=
sc.Status.ToString().Equals(
"
Running
"
);
if
(stopText
&&
Runned)
{
label1.Text
=
"
Current status is:Stopped
"
;
sc.Stop();
StartSql.Text
=
"
Start
"
;
}
else
if
(startText
&&
!
Runned)
{
label1.Text
=
"
Current status is:Running
"
;
sc.Start();
StartSql.Text
=
"
Stop
"
;
}
else
{
MessageBox.Show(
"
出现异常,请联系开发人员!
"
,
"
警告
"
, MessageBoxButtons.OK);
}
sc.Close();
}
注
:StartSql是一个按钮,添加一个引用ServiceProcess
查看全文
相关阅读:
【26.09%】【codeforces 579C】A Problem about Polyline
【水水水】【洛谷 U4566】赛车比赛
【24.58%】【BZOJ 1001】狼抓兔子
【心情】2016ICPC青岛站打铁记
【record】11.7..11.13
Identifying a distributed denial of service (DDOS) attack within a network and defending against such an attack
在页面所有元素加载完成之后执行某个js函数
day38 01-Spring框架的概
day37 10-SH整合的案例练习
day37 09-Struts2和Hibernate整合环境搭建
原文地址:https://www.cnblogs.com/Kennytian/p/1022503.html
最新文章
python 百度top100和top500歌曲下载
百度MP3 SHELL脚本
用批处理整理百度MP3上歌曲排行榜MP3及LRC文件的批量下载链接地址(含图文教程)
男婴遭遇车祸受伤送医 医生以先挂号为由拒急救
关于 bochs 和 bochs 调试
linux C 语言的 system(执行shell 命令)
Linux的成长和UNIX之殇
修改及查看mysql数据库的字符集
MySql中文乱码问题解决
mysqldump只导出数据或者只导出表结构
热门文章
Releases/18/FeatureList —— RHEL7——CentOS7
linux pdf
金蝶V10.0专业版 安装步骤
金蝶软件核算项目的介绍及使用
mysql 并发 行锁 inoodb
【22.70%】【codeforces 591C】 Median Smoothing
【16.23%】【codeforces 586C】Gennady the Dentist
【33.33%】【codeforces 586D】Phillip and Trains
【25.00%】【codeforces 584E】Anton and Ira
【17.07%】【codeforces 583D】Once Again...
Copyright © 2011-2022 走看看