Server names or instance names

Hello there. I'm trying to populate a drop down box with a list of all available instances of SQL server (express or not) available on a network. To list all instances I'm using EnumAvailableServers() in SmoApplication.

The issue is that the Instance column in the returned data table is always empty, and both the Name and the Server columns contain the same string -- the name of the computer the SQL server is installed. Locally I have SSE installed, the instance name is <computer_name>\SQLEXPRESS, however, using Smo I can't seem to get to the either full instance name or just the instance name. I can't assume SQLEXPRESS, since there may be more than one installed.

Alternately I used EnumRegisteredServers() in SmoApplication.SqlServerRegistrations and that, while returning instance information (can be retrieved from the RegisteredServer in the returned collection), doesn't always return the remote SQL servers in the list.

Any idea how can this be done? Maybe I'm going at it the wrong way, maybe there's another class / method I need to use to retrieve all instances?

Thank you

[1138 byte] By [CalinMac] at [2007-12-23]
# 1
For more information habe a look on that article http://www.sqlserver2005.de/articles/1

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

JensSuessmeyer at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Express...
# 2

Thank you, I will try that, although if I look at the returned datatable (with the dt viewer) I do not see an instance anywhere -- not only the Instance column is empty, but the Name and Server columns only contain the server name.

Maybe the viewer is also using the enumerator approach, thus (as you said) not complete, so I'll try your approach.

Thanks again

CalinMac at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Express...
# 3
The api can find the default instances easily becasuse they are bound to the default port of SQL Server. If you start the SQL browser service on the computer the other named instances which are on other port than the default one will be shown as well. Did you already start the SQL Server Browser service on the computer ?

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

JensSuessmeyer at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Express...
# 4

Well, that is the other side of the story -- asked another question today on the same forum regarding database creation with SMO, mostly in the case where SSE is not properly installed. I have code in place to start the browser service automatically if it's not yet started, so this is solved.

Thanks again for your help, Jens!

CalinMac at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Express...

SQL Server

Site Classified