检查是否安装了SQL Server(所有版本)? [英] Check if SQL server (any version) is installed?

查看:180
本文介绍了检查是否安装了SQL Server(所有版本)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到如果在计算机上安装SQL服务器。它可以是SQL服务器(7,2005,8,SQL前preSS等)的任何版本。我们需要知道这个信息,因为我们正在编写一个安装程序,需要展示给用户,如果SQL服务器尚未找到,安装无法继续进行。

I need to find if SQL server is installed on a machine. It could be any version of SQL server (7, 2005,8, sql express etc). We need to know this information as we are writing an installer and need to show to the user that if SQL server has not been found, the installation cannot proceed.

我已经看到了使用注册表版本,WMI,SMO或只是简单地连接到SQL Server实例(虽然没有任何帮助,因为我们不知道服务器名称)。

I have seen versions that use the registry, wmi, SMO or simply just connect to SQL server instance (although would not help here as we do not know the server name).

我们正在使用的维克斯安装程序。

We are using the Wix Installer.

什么是做正确的方法是什么?

What is the correct way to do this?

JD

推荐答案

一个简单的方法来列出网络上的所有的SQL Server是这样的:

A simple way to list all SQL Servers on the network is this:

using System.Data;
using System.Data.Sql;
using System;

...

SqlDataSourceEnumerator sqldatasourceenumerator1 = SqlDataSourceEnumerator.Instance;
DataTable datatable1 = sqldatasourceenumerator1.GetDataSources();
foreach (DataRow row in datatable1.Rows)
{
    Console.WriteLine("****************************************");
    Console.WriteLine("Server Name:"+row["ServerName"]);
    Console.WriteLine("Instance Name:"+row["InstanceName"]);
    Console.WriteLine("Is Clustered:"+row["IsClustered"]);
    Console.WriteLine("Version:"+row["Version"]);
    Console.WriteLine("****************************************");
}

这个博客帖子。

这篇关于检查是否安装了SQL Server(所有版本)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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