oj said:
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
}
}
I appreciate the help and it's my fault for leaving this an open-ended
question. Let me try again.
I am trying to make a mini-Enterprise Manager and so far I can get the
server groups and list the registered servers but when I try to get a
specific server from the SQLServers collection (by name) it doesn't return
anything.
This should be possible, right?
Following your example above I should be able to the following:
SQLServer2 currentSQLServer = oApp.SQLServers("DBName")
But for some reason it comes back a null object.
I have no idea how to continue. (Loop through the list until I find the
SQLServer.ServerName = "DBName"?)
Tom P.