You will need to create an interop for dmo before you can use it. Here are
the steps:
1. add a reference to dmo - browse to sqldmo.dll (normally found under
\tools\binn of sql directory)
2. and here is a simple code to get you started
using System;
using SQLDMO;
namespace dmo2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ListSQLs();
}
public static void ListSQLs()
{
//
// List available SQL Server on subnet
//
SQLServer2 oServer = new SQLServer2();
Application oApp = oServer.Application;
NameList oList = oApp.ListAvailableSQLServers();
for (int i=0; i < oList.Count; i++)
{
Console.WriteLine(oList.Item(i));
}
Console.Read();
} //end ListSQLs
}
}