停止VB应用程序中的SQL Server吗? [英] Stop a SQL Server out of a VB Application?

查看:94
本文介绍了停止VB应用程序中的SQL Server吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正忙着开发一个应用程序来做备份

但是某些备份需要在复制备份的PC上停止sql服务器.

所以我想知道是否有办法从vb.net应用程序停止SQL Server?

您需要导入什么才能获取Controller?

编码在vb.net中不起作用

hi people i am busy developing a application to do backups

but some of the backups needs a sql server to be stopped on the pc from where the backups are copied from.

so i am wondering if there is a way to stop a sql server from a vb.net application?

and what do you need to import to get the Controller?

the coding doesn''t work in vb.net

dont know where to import the serviceController from?

推荐答案

基本上,SQL Server只是您需要停止的服务.

使用此代码:

Basically SQL server is just a service which you need to stop.

Use this Code :

ServiceController controller = new ServiceController();
controller.MachineName = "MachineName";
controller.ServiceName = "SQLSERVER2008";

if(controller.Status == ServiceControllerStatus.Running)
     controller.Stop();

controller.WaitForStatus(ServiceControllerStatus.Stopped);



干杯..

:rose:



Cheers..

:rose:


这篇关于停止VB应用程序中的SQL Server吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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