private void LoadSchema(DataSet ds, WmiCommand command, WmiDataReader reader) { //Match the query "table". string name = _commandtable.Match(command.CommandText).Groups["table"].Value; if (ds.Tables.Contains(name)) { ds.Tables.Remove(name); } DataTable table = new DataTable(name); //Use the first object to build the table structure. ManagementObject one = reader.GetOne(); if (one != null) { foreach (PropertyData prop in one.Properties) { table.Columns.Add(prop.Name, WmiConvert.WmiToClr(prop.Type)); } } //Add dummy column if no data is found. For consistency with other ADO.NET providers which always load the schema. if (table.Columns.Count == 0) { table.Columns.Add("Object", typeof(string)); } ds.Tables.Add(table); }
/// <summary> /// Creates an instance of the adapter with the values specified. /// </summary> public WmiDataAdapter(string selectCommand, string connectionString) { _select = new WmiCommand(selectCommand, new WmiConnection(connectionString)); }
/// <summary> /// Creates an instance of the adapter with the values specified. /// </summary> public WmiDataAdapter(WmiCommand selectCommand, WmiConnection connection) { _select = selectCommand; _select.Connection = connection; }
/// <summary> /// Creates an instance of the adapter with the values specified. /// </summary> public WmiDataAdapter(WmiCommand selectCommand) { _select = selectCommand; }