更改SQL Server设置编程 [英] Changing SQL Server settings programmatically

查看:120
本文介绍了更改SQL Server设置编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我请求您仔细阅读我的问题。

I request you to read my question carefully.

您可能会在安装VS2005 / 2008与SQL Server Express版本都知道,在SQL Server Windows身份验证模式,在默认情况下运行。您可以使用SQL Server Management Studio来改变模式以混合模式(Windows和SQL Server身份验证模式)。

You might know when you install VS2005/2008 with SQL Server Express edition, the SQL Server operates in Windows authentication mode by default. You can use the SQL Server Management Studio to change the mode to Mixed mode (Windows and SQL Server Authentication mode).

同样允许SQL服务器通过TCP远程连接/ IP,您需要使用SQL Server配置管理器,然后选择协议SQLEXPRESS,然后更改为TCP / IP选项的设置。

Similarly to allow the SQL Server remote connection through TCP/IP, you need to use SQL Server Configuration Manager then select Protocol for SQLEXPRESS and then change the setting for Tcp/IP option.

我需要的编程方式使用C#来自动完成这一过程。也就是说,我需要编写C#程序更改模式或更改TCP / IP设置等。

What i need is to automate this process programmatically using C#. That is, i need to write a c# program to change the mode or change the tcp/ip settings etc.

谁能给我提供这样的服务,我怎么能做到呢?

Can anyone provide me help on this, how could i do that?

感谢您与我们分享您的宝贵时间。

Thank you for sharing your valuable time.

推荐答案

您应该使用SQL Server管理对象( SMO ) - 这是编程方式管理SQL Server的API

You should use SQL Server Management Objects (SMO) - this is an API for managing SQL Server programmatically.

更新:

被证明是有点棘手:Server.LoginMode(读/写),服务器.TcpEnabled和Server.NamedPipesEnabled(只得到,可惜)。为了修改协议,您需要检查Microsoft.SqlServer.Management.Smo.Wmi命名空间(因此从另一端走出):

Proves to be a bit tricky: Server.LoginMode (read/write), Server.TcpEnabled and Server.NamedPipesEnabled (get only, unfortunately). In order to modify protocols, you need to examine Microsoft.SqlServer.Management.Smo.Wmi namespace (hence going from 'the other end'):


  • ServerProtocol - 代表服务器协议

  • ServerProtocolCollection - 一个给定的服务器上定义的所有协议的集合

这篇关于更改SQL Server设置编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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