Using system;
Using system. Data. SQL;
Using system. text;
Namespace allsqlserver
{
Class Program
{
Static void main (string [] ARGs)
{
// Sqldmo. namelist names;
// Sqldmo. applicationclass AC = new sqldmo. applicationclass ();
// Names = ac. listavailablesqlservers ();
// String [] serverlist = new string [names. Count];
// For (INT I = 0; I <serverlist. length; I ++)
//{
// Serverlist [I] = names. item (I );
//}
// Foreach (string STR in serverlist)
//{
// Console. writeline (STR );
//}
Sqldatasourceenumerator instance = sqldatasourceenumerator. instance;
System. Data. datatable table = instance. getces CES ();
Displaydata (table );
Console. Readline ();
}
Private Static void displaydata (system. Data. datatable table)
{
Foreach (system. Data. datarow row in table. Rows)
{
Console. writeline ("server name = {0}", row ["servername"]);
Console. writeline ("Instance name = {0}", row ["instancename"]);
Console. writeline ("integration verification = {0}", row ["isclustered"]); // Windows Authentication and SQL Server Authentication
Console. writeline ("version = {0}", row ["version"]); // 8. * is SQL 2000, 9. * is SQL 2005
Console. writeline ("=========================== ");
}
}
}
}
ArticleReferenced from: