This section of the chapter takes an in-depth look at the ExtendedProperties property of the DataSet component. Since this property is of type System.Data.PropertyCollection, most of what you read here will apply to any component or object inheriting from the System.Data. PropertyCollection class.
The ExtendedProperties property is worth discussing in this chapter because it is equipped with properties and methods of its own that provide you with many ways to customize, extend, and, therefore, add power to the generic DataSet component. To use ExtendedProperties effectively, you need to know two basic things:
How to add an extended property to a DataSet
How to read and write values to the property
To add an extended property to a DataSet, use the Add() method. The following example adds two extended properties to a DataSet:
Dim ds as New DataSet () 'Initialize DataSet With ds.ExtendedProperties .Add ("username", "Terrence") .Add ("password", "pizza") End With
There are several ways to read the values of the extended properties.
To read the value of one single extended property, use the Item(index) property:
With ds.ExtendedProperties MsgBox(.Item(0)) ‘Display message box showing the value of 'the username property — "Terrence" End With
To obtain the values of all the extended properties as a collection, use the Values property to populate an ICollection component:
Dim propColl as ICollection With ds.ExtendedProperties propColl = .Values End With