HotDog's Blog

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

vbCity Blogs moved to:
http://cs.vbcity.com/blogs
  Home :: Syndication  :: Login

JunJuly 2009Aug
SMTWTFS
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

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 on Monday, June 06, 2005 3:55 AM