SQL Server实例 [英] Sql Server Instances

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

问题描述

你好!

我试图枚举安装在本地计算机上的Sql Server 2005及以上版本的实例.
我知道有SMO.但是SMO仅检测Sql Server 2005版本或更低版本.我也尝试过使用注册表,但是注册表重定向存在问题.

我有x64平台,我的应用程序适用于x86,因此它将我重定向到.. \ WOW6432NODE \ ...
另一个可行的解决方案是检查服务名称,但这可能非常不可靠,因为该服务可以根据用户选择具有任何名称.

那么,解决方案是什么?是否可以将SMO用于SQL Server 2008,或者如何跳过C#中的注册表重定向?(不适用于c ++).

谢谢
Bogdan

Hello !

I am trying to enumerate Sql Server 2005 and above instaces installed on local machine.

I know that there is SMO. But SMO detects just Sql Server 2005 versions or lower. I have also tried to use registry but there is a problem with registry redirection.

I have x64 platform and my application is for x86 so it redirects me to ..\WOW6432NODE\...
Another posible solution would be to check service names but this can be very unreliable since the service can have any name as per user choice.

So, what''s the solution? Can I use SMO for SQL Server 2008, or how can I skip the registry redirection from C#?(not with c++).

Thank you,
Bogdan

推荐答案

Here''s[^] an implementation with c#.

Using this method you''ll need to parse some strings, but it''s a complete solution otherwise.

Cheers.


是的,您可以将SMO与SQL Server 2008一起使用.请参见这里.与SQL Server 2005相同.我认为您可能要对SQL Server 2000使用DMO: http://support.microsoft.com/kb /326613 .
Yes, you can use SMO with SQL Server 2008. See here. Same for SQL Server 2005. I think you may want to use DMO for SQL Server 2000: http://support.microsoft.com/kb/326613.


SMO类结构变化非常快.为了支持越来越多的功能,SQL Server 2005 Management Studio中存在的大多数类在2008年进行了更改.

因此,我认为您需要重新创建或修改您的应用程序以支持它们.

除此之外,您还可以对您引用的所有dll使用本地复制",并将其与您的应用程序一起提供,并允许您在任何环境中执行代码,而无需使用来自GAC的dll.

为此,只需从Visual Studio解决方案中选择dll并转到属性.选择CopyLocal为true.

现在,如果将相同的解决方案放置到装有SQL Server 2008的计算机上,它将可以使用.

:rose:
SMO class structure changes very quickly. To support more and more functionality, most of the classes that were there in SQL server 2005 Management studio is changed in 2008.

So i think you need to recreate or modify your application to support them.

Other than that you can use Copy Local to all the dlls that you refer and ship the same with your application, and will let you do the code in any environment without using the dlls that are coming from GAC.

To do that, Just select the dll from Visual Studio Solution and go to properties. Select CopyLocal to true.

Now if you place the same solution to a machine which has SQL Server 2008, it will work.

:rose:


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

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