Show All

# DataObjects Collection

DataObjects DataObject

Contains a DataObject object for each secondary data source used within a Microsoft Office InfoPath 2003 form. Each DataObject object provides access to the particular data adapter object that was used to connect to the external data source.

## Remarks

The DataObjects collection implements properties that can be used to access a form's associated DataObject objects, and it is accessible through the DataObjects property of the XDocument object.

Note The DataObjects collection can be used only to get the count of DataObject objects that it contains or to return a reference to a specified DataObject object. It cannot be used to create, add, or remove DataObject objects.

## Using the DataObjects collection

In the following example, implemented as an OnClick event handler for a button on a form, the DataObjects property of the XDocument object is used to set a reference to the DataObjects collection. The code then loops through the collection and displays the positional index and name of each DataObject object that it contains:

    function ShowDataObjectNames::OnClick(eventObj)
    {
       // Set a reference to the DataObjects collection.
       var objDataObjects = XDocument.DataObjects;

       // Loop through the collection and display the name
       // of each DataObject object that it contains.
       for (i=0; i < objDataObjects.Count; i++)
       {
          XDocument.UI.Alert("Data object " + i + ": " +
             objDataObjects(i).Name);
       }
       objDataObjects = null;
    }

For more information about using the DataObjects collection, see Accessing external data sources.

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp