C#中启动sql服务的一段简单代码

System.Diagnostics.ProcessStartInfo libt = new System.Diagnostics.ProcessStartInfo();
  libt.FileName 
= "cmd.exe";
  libt.Arguments 
= "/c net start mssql$db2005";  // "c" 后面的是Doc语句
  libt.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //将窗体模式设为隐藏模式
  System.Diagnostics.Process.Start(libt);

 

 附注:

运行环境 :SQL2005 、VS2005

通过dos命令启动服务

 

posted @ 2009-04-13 21:46  淹死的鱼  阅读(316)  评论(0编辑  收藏  举报