Hi. I've successfully used WMI to get instances of MSSQL_SQLServer running on a server, but I'm having trouble getting a specific instance.

The documentation says that it is possible to ask for a specific instance of a class in WMI rather than using enumeration. But the examples provided are using VB GetObject().

The code below is successful:

wmiNamespace = @"\\.\root\MicrosoftSQLServer";
wmiSQLServerClass = new ManagementPath(@"\\.\root\MicrosoftSQLServer:MSSQL_SQLServer");
ManagementScope objManagementScope = new ManagementScope(wmiNamespace);

// Connect to the SQLServer Namespace.
objServerClass = new ManagementClass(wmiSQLServerClass);

At this point I can use

But I'm lost when it comes to getting the specific instance I want.


From: Ticean Bennett

Posted by a user from .NET 247 (http://www.dotnet247.com/)