HotDog's Blog

Hotdog (Robert Verpalen) about C# and vb.net

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

MayJune 2005Jul
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

Monday, June 06, 2005 #

One of the things that was always an issue (at least for me ;-) ) was to get a list of all sql servers available to the machine the code was run at.

Sure, there was the sqldmo,netserverenum and even a method using odbc, but each needed api calls (or interop). But for those of you interested: great news: whidbey has the requiring of the information build in !!!! :-)
The SqlDataSourceEnumerator gives back a datatable with information on the available servers. (See the link to find out precisely what information)

From .net 2.0 and up, filling a listbox with the server-names can be as simple as:
listBox1.DisplayMember = "ServerName";
listBox1.DataSource = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources();

posted @ 3:55 AM