从.net应用程序启动SQL Server 2008 [英] Starting SQL Server 2008 from .net application

查看:96
本文介绍了从.net应用程序启动SQL Server 2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的编码员,



我希望在应用程序启动时从我的应用程序启动SQL服务器服务并在关闭应用程序时停止服务。



怎么做?



谢谢和问候。

Dear Coders,

I want to start SQL server service from my application when the application starts & stop the service when i close the application.

How to do this?

Thanks & Regards.

推荐答案

按照Wes的说法,阅读以下内容: http://stackoverflow.com/questions/467367/how-can-i-programmatically-stop-start-a-windows-service-on-a-remote-box [< a href =http://stackoverflow.com/questions/467367/how-can-i-programmatically-stop-start-a-windows-service-on-a-remote-boxtarget =_ blanktitle =新窗口> ^ ]
Do as Wes said, read the following : http://stackoverflow.com/questions/467367/how-can-i-programmatically-stop-start-a-windows-service-on-a-remote-box[^]


System.Diagnostic.Process.Start(sqlservr.exe);将它插入一个事件,你的SQL服务器将随时启动。
System.Diagnostic.Process.Start("sqlservr.exe"); insert it into an event and yr sql server will start whenever you want.


尝试

{

ServiceController controller = new ServiceController( );

controller.MachineName =" Machine-Name";

controller.ServiceName =" MSSQL
try
{
ServiceController controller = new ServiceController();
controller.MachineName = "Machine-Name";
controller.ServiceName = "MSSQL


这篇关于从.net应用程序启动SQL Server 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆