VilemRousi
VilemRousi

Reputation: 2142

How to Enumerate SQL Server Instances

I´d like to have my application return instances of SQL Server 2008 R2 Developer/Express.

I´m using:

System.Data.DataTable lokalni_servery = Microsoft.SqlServer.Management.Smo.SmoApplication.EnumAvailableSqlServers();

foreach (System.Data.DataRow row in lokalni_servery.Rows)
{
    local_servers.Items.Add(row["Server"].ToString());
}

On my friend´s notebook with SQL Server 2008 R2 express 32 bit, it doesn´t find anything, but on my notebook with SQL Server 2008 R2 Developer 64 bit, it finds it almost everytime. I need to be able to find this instance of SQL on both machines.

Does anybody know why the application is behaving like this?

Is there a way to alter the method allowing for both notebooks to find the instance?

Upvotes: 1

Views: 1924

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112712

SmoApplication.EnumAvailableSqlServers enumerates available instances, which means that the servers must be running. Just the fact that they are installed is not enough.

Also the SQL Server Browser Service must be running!

See How to: Start and Stop the SQL Server Browser Service (SQL Server Express) on MSDN

Upvotes: 1

Related Questions