Saturday, November 15, 2008

Getting all Sql Servers In a Network in .NET

//first add reference of Microsoft SQLDMO Object Library

SQLDMO.Application app = new SQLDMO.ApplicationClass();
SQLDMO.NameList names = app.ListAvailableSQLServers();
string serverName = "";

for (int i = 1; i <= names.Count; ++i)
{
serverName = names.Item(1);
MessageBox.Show(serverName);
}

No comments: