Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

WMI SQL Queries with Joins

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucas Ponzo - 06 May 2004 21:41 GMT
In the samples I saw with WMI, we can use a SQL like query to get system information ( "Select * From SomeWMIClass" ).

Can I use joins to get WMI classes correlated data ??

For example: I want to join Win32_NetworkAdapter with Win32_NetworkAdapterConfiguration to get a result set with information from the two classes in a single resultset.

How to join multiple WMI classes ??

Something like this

Select Win32_NetworkAdapter.AdapterType, Win32_NetworkAdapter.Caption,   Win32_NetworkAdapterConfiguration.IPAddress,  Win32_NetworkAdapterConfiguration.MACAddress
From  Win32_NetworkAdapter, Win32_NetworkAdapterConfiguration
Where Win32_NetworkAdapter.ID = Win32_NetworkAdapterConfiguration.ID ( ??

Thanks
Tian Min Huang - 07 May 2004 11:00 GMT
Hi,

Thanks for your post. I am checking this issue and will update you with my
findings.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Tian Min Huang - 10 May 2004 08:02 GMT
Hello,

Based on my research, you can do that by view provider by creating the
appropriate mof. Save following text between the lines in a mof file say
a.mof and then run
  mofcomp  a.mof

Then connect to root\sample_views namespace and get instances of class  
Join_NetAdapterAndConfig.

//----------------------mof content-----------------
#pragma namespace("\\\\.\\root\\sample_views")

instance of __Win32Provider as $DataProv
{
           Name = "MS_VIEW_INSTANCE_PROVIDER";
           ClsId = "{AA70DDF4-E11C-11D1-ABB0-00C04FD9159E}";
           ImpersonationLevel = 1;
           PerUserInitialization = "True";
};

instance of __InstanceProviderRegistration
{
           Provider = $DataProv;
           SupportsPut = True;
           SupportsGet = True;
           SupportsDelete = True;
           SupportsEnumeration = True;
           QuerySupportLevels = {"WQL:UnarySelect"};
};


[JoinOn("Win32_NetworkAdapter.index =
Win32_NetworkAdapterConfiguration.Index"),
ViewSources
           {
           "Select * from Win32_NetworkAdapter",
           "Select * from Win32_NetworkAdapterConfiguration"
           },
ViewSpaces
           {
           "\\\\.\\root\\cimv2",
           "\\\\.\\root\\cimv2"
           },
dynamic, provider("MS_VIEW_INSTANCE_PROVIDER")]
class Join_NetAdapterAndConfig
{          

           [PropertySources{"AdapterType",""}]
           string AdapterType;
           
           [PropertySources{"Caption",""}]
           string Caption;
           
           [key,
           PropertySources{"index","index"}]
           uint32 ID;
           
           [PropertySources{"","IPAddress"}]
           string IPAddress[];

           [PropertySources{"","MACAddress"}]
           string MACAddress;

};
//----------------------end of-------------------------

Here's the link to learn more about view provider
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/view_provider.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.