Share via


DataAdaptersCollection interface

Contains a data adapter object corresponding to each data connection used within a Microsoft InfoPath form.

Namespace:  Microsoft.Office.Interop.InfoPath
Assembly:  Microsoft.Office.Interop.InfoPath (in Microsoft.Office.Interop.InfoPath.dll)

Syntax

'Declaration
<GuidAttribute("096CD692-0786-11D1-95FA-0080C78EE3BB")> _
Public Interface DataAdaptersCollection _
    Inherits DataAdapters
'Usage
Dim instance As DataAdaptersCollection
[GuidAttribute("096CD692-0786-11D1-95FA-0080C78EE3BB")]
public interface DataAdaptersCollection : DataAdapters

Remarks

This type is a wrapper for a COM interface implemented by a coclass that is required by managed code for COM interoperability. To access the members specified by this interface, use the type that wraps the coclass that implements this interface. For information about that type, including usage, remarks, and examples, seeDataAdapters.

Each data connection is used to retrieve data (inserted into the main data source or into a secondary data source) or to submit data.

A data connection used to retrieve data for the main data source will correspond to one of the following data adapter object types:

Note

An ADOAdapter object used to retrieve data for the main data source can also submit data.

A data connection used to retrieve data for a secondary data source will correspond to one of the following data adapter object types:

A data connection used only for submitting data will correspond to one of the following data adapter object types:

The DataAdapters collection can be accessed using the DataAdapters property of the XDocument object.

Note

To use properties or methods of a data adapter object, it is necessary to cast the object returned from the DataAdaptersCollection object to the specific data adapter that it represents before you can access those members. For more information about working with data adapters, see How to: Access External Data Sources

Examples

In the following example, an ADOAdapter object connected to the Employees table of the Northwind database is retrieved from the DataAdapters collection:

// retrieve the Employees Adapter from the DataAdapters collection
ADOAdapter employeesDA = (ADOAdapter)thisXDocument.DataAdapters["Employees"];

In the following example, an XML document called "form1", available as an XML file data connection, is retrieved from the DataAdapters collection. Various properties of the connection are displayed in message boxes:

DataAdapters dataAdapters;
dataAdapters = thisXDocument.DataAdapters; 
XMLFileAdapterObject queryXMLFile = (XMLFileAdapterObject)dataAdapters["form1"];
thisXDocument.UI.Alert("Query - XML file adapter"); 
thisXDocument.UI.Alert("Name: " + queryXMLFile.Name);
thisXDocument.UI.Alert("QueryAllowed: " + queryXMLFile.QueryAllowed);
thisXDocument.UI.Alert("SubmitAllowed: " + queryXMLFile.SubmitAllowed);
thisXDocument.UI.Alert("FileURL: " + queryXMLFile.FileURL);
// Perform the query.
try
 {
  queryXMLFile.Query();
 }
catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to query.\n\n" + ex.Message);
 }
// Perform the submit.
try
 {
  queryXMLFile.Submit();
 }
catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to submit.\n\n" + ex.Message);
}

See also

Reference

DataAdaptersCollection members

Microsoft.Office.Interop.InfoPath namespace