
Using the DataObjects collection and the DataObject object
The DataObjects collection is accessed through the DataObjects property of the XDocument object. For example, if you create a secondary data source named CityList that is based on a table in a Microsoft Access database, you can use the DataObjects collection to set a reference to the DataObject object that represents the external data source.
In the following code sample, the name of the secondary data source is passed to the Item property of the DataObjects collection, which returns a reference to the DataObject object, which, in this case, is associated with an ADOAdapter data adapter object. Using the QueryAdapter property of the DataObject object, the ADOAdapter data adapter object's Connection property displays the ADO connection string in a message box.
function TestDataObjects()
{
var objDataObject;
// Set a reference to the specified data object.
objDataObject = XDocument.DataObjects("CityList");
// Display the connection information for the ADOAdapter object.
XDocument.UI.Alert("Data Adapter: " + objDataObject.QueryAdapter.Connection);
objDataObject = null;
}
To manipulate the data that is contained in a secondary data source, use the DOM property of the DataObject object to return a reference to the XML DOM containing the data. When you have the reference to the XML DOM, you can use any of its properties or methods to manipulate the data that it contains.