Show All

# DataObject Object

DataObjects DataObject

Represents a link to the data adapter of a secondary data source. The DataObject object acts as an intermediary between a Microsoft Office InfoPath 2003 form and the data adapter object that is used to access data that is contained in an external data source.

The DataObject object provides properties and methods that can be used to programmatically interact with data adapter objects, including retrieving information about the data adapter objects and accessing the data that they connect to. The DataObject object is accessible through the DataObjects property of the XDocument object.

## Remarks

An external data source can take the form of a Microsoft Access or Microsoft SQL Server database, an .xml file, or an XML Web service. The type of data adapter object used to access the external data source depends on the type of data source. The DataObject object provides a common set of properties and a method that can be used for all types of data adapter objects, and each of the data adapter objects provides its own set of properties and methods.

Microsoft Office InfoPath 2003 supports three types of data adapters:

1. ActiveX Data Objects Represented by the ADOAdapter object.
2. Web services Represented by the WebServiceAdapter object.
3. XML file Represented by the XMLFileAdapter object.

## Using the DataObject object

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 is used to display 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;
    }

For more information about using the DataObject object, 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