DataObject Object

InfoPath Developer Reference

Represents a link to the data adapter of a secondary data source.

Version Information
 Version Added:  InfoPath 2003

Remarks

The DataObject object acts as an intermediary between a Microsoft Office InfoPath 2007 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.

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.

Office InfoPath 2007 supports four types of data adapters:

For more information about using the DataObject object, see Working with data in a form's secondary data sources.

Example

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.

JScript
  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;
}

See Also