473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

c# sms 2003 add to collection

In the process of developing a C# GUI for our desktop support team. Basic
code following allows me to query the contents of a collection. Would
someone help me by posting a sample of how to add workstations to a
collection. Thanks

---------------------------------------------------------------------
const string sSMSCollectionProject2003 = "00100037";
const string sSMSCollectionVisio2003 = "00100038";

// Connect to WMI with the Systems.Management .NET Object
// Objects below belong to the Systems.Management Namespace

//Establish Connection Options
ConnectionOptions oConnectionOptions = new ConnectionOptions();
oConnectionOptions.Username = "LEDCOR\\svc_sms";
oConnectionOptions.Password = "master54*";
oConnectionOptions.Authentication = AuthenticationLevel.Default;
oConnectionOptions.Impersonation = ImpersonationLevel.Impersonate;

// Instantiate Management Object Scope on Remote System, and
Remote WMI Path for SMS via the Connection Options
ManagementScope oManScope = new
ManagementScope("\\\\701-1235\\root\\sms\\site_001", oConnectionOptions);

//Query String and Creating a Query Object from that String
string sWQL = "SELECT * FROM SMS_CM_RES_COLL_" +
sSMSCollectionVisio2003;
ObjectQuery oManObjectQuery = new ObjectQuery(sWQL);

// SearchObject Searches Remote Management Scope with Query
ManagementObjectSearcher oManSearcher1 = new
ManagementObjectSearcher(oManScope, oManObjectQuery);

// SearchObject is converted to a Collection for interoperatbility
ManagementObjectCollection oManQueryCollection1 =
oManSearcher1.Get();

foreach (ManagementObject oManObj in oManQueryCollection1)
{
int iNumber = 1;
//MessageBox.Show("objects : " + iNumber);
iNumber++;
//MessageBox.Show(oManObj.Properties.ToString());
// Determines The Names of the Columns in a Collection
PropertyDataCollection.PropertyDataEnumerator
propertyEnumerator = oManObj.Properties.GetEnumerator();

while (propertyEnumerator.MoveNext())
{
PropertyData smsCollection =
(PropertyData)propertyEnumerator.Current;
//MessageBox.Show("Property found: " +
smsCollection.Name);
MessageBox.Show("Value of Property: " +
smsCollection.Value);
}
}
--------------------------------------------------------------------
Oct 26 '06 #1
1 2158
Check with WMI site. Your piece of code does not seem to be logic to add the
part you mentioned in it.

chanmm

"jkinneberg" <jk********@discussions.microsoft.comwrote in message
news:B2**********************************@microsof t.com...
In the process of developing a C# GUI for our desktop support team. Basic
code following allows me to query the contents of a collection. Would
someone help me by posting a sample of how to add workstations to a
collection. Thanks

---------------------------------------------------------------------
const string sSMSCollectionProject2003 = "00100037";
const string sSMSCollectionVisio2003 = "00100038";

// Connect to WMI with the Systems.Management .NET Object
// Objects below belong to the Systems.Management Namespace

//Establish Connection Options
ConnectionOptions oConnectionOptions = new ConnectionOptions();
oConnectionOptions.Username = "LEDCOR\\svc_sms";
oConnectionOptions.Password = "master54*";
oConnectionOptions.Authentication =
AuthenticationLevel.Default;
oConnectionOptions.Impersonation =
ImpersonationLevel.Impersonate;

// Instantiate Management Object Scope on Remote System, and
Remote WMI Path for SMS via the Connection Options
ManagementScope oManScope = new
ManagementScope("\\\\701-1235\\root\\sms\\site_001", oConnectionOptions);

//Query String and Creating a Query Object from that String
string sWQL = "SELECT * FROM SMS_CM_RES_COLL_" +
sSMSCollectionVisio2003;
ObjectQuery oManObjectQuery = new ObjectQuery(sWQL);

// SearchObject Searches Remote Management Scope with Query
ManagementObjectSearcher oManSearcher1 = new
ManagementObjectSearcher(oManScope, oManObjectQuery);

// SearchObject is converted to a Collection for
interoperatbility
ManagementObjectCollection oManQueryCollection1 =
oManSearcher1.Get();

foreach (ManagementObject oManObj in oManQueryCollection1)
{
int iNumber = 1;
//MessageBox.Show("objects : " + iNumber);
iNumber++;
//MessageBox.Show(oManObj.Properties.ToString());
// Determines The Names of the Columns in a Collection
PropertyDataCollection.PropertyDataEnumerator
propertyEnumerator = oManObj.Properties.GetEnumerator();

while (propertyEnumerator.MoveNext())
{
PropertyData smsCollection =
(PropertyData)propertyEnumerator.Current;
//MessageBox.Show("Property found: " +
smsCollection.Name);
MessageBox.Show("Value of Property: " +
smsCollection.Value);
}
}
--------------------------------------------------------------------

Oct 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
0
by: Grant | last post by:
I've cross-posted this in the COM+ group as well - apologies if that's a no-no. But the problem might be caused by either... interop or just plain COMAdmin....
0
by: don | last post by:
Is it possible to access the amazon movie collection via web services useing visual studio.net 2003, framework 1.1 ? I'm writing a personal movie database system using asp.net and would like to...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
by: Bill Sun | last post by:
Hi, I want to compile the MS's program: ADOXCreateDatabaseX.cpp on VC7 of .Net 2003. The compiler always told me: c:\project\console\console\Debug\msado15.tlh(2374) : error C2059: syntax error :...
0
by: JackWarner | last post by:
OK, I'm finally getting our organization to upgrade from v6, and the first project I try to recompile I run into hairy problems. We've used this ATL COM collection class for years. It looks like...
12
by: Gary Napolitano | last post by:
I have VB .net (2002 personal ownership) at home, and .net 2003 at my office (we're an MSDN developer shop) and I found that I cannot write code home, bring it to work, and back home again. This...
1
by: jeffbernstein | last post by:
Greetings. I have a ListView control loaded with several items and I'd like to explore the collection via the Watch Window in Visual Studio .NET 2003. My textbook was written for the previous...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.