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.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.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 coclass that is required by managed code for COM interoperability. Use this type to access the members of the COM interface implemented by this coclass. For information about the COM interface, including a link to descriptions of its members, 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 Using the InfoPath 2003 Object Model.

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;
XMLFileAdapterObject xmlFileAdapterObject;

dataAdapters = thisXDocument.DataAdapters; 
xmlFileAdapterObject = dataAdapters["form1"] as XMLFileAdapterObject;

if (xmlFileAdapterObject == null)
{
 thisXDocument.UI.Alert("The DataAdapter does not exist or is not an XMLFileAdapterObject.");
}
else
{
 thisXDocument.UI.Alert("XML file adapter" + "\n\n" + "Name: " + xmlFileAdapterObject.Name + "\n" + "QueryAllowed: " + xmlFileAdapterObject.QueryAllowed+ "\n" + "SubmitAllowed: " + xmlFileAdapterObject.SubmitAllowed+ "\n" + "FileURL: " + xmlFileAdapterObject.FileURL);

 // Perform the query.
 try
 {
  xmlFileAdapterObject.Query();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to query.\n\n" + ex.Message);
 }

 // Perform the submit.
 try
 {
  xmlFileAdapterObject.Submit();
 }
 catch (Exception ex)
 {
  thisXDocument.UI.Alert("Failed to submit.\n\n" + ex.Message);
 }
}

See also

Reference

DataAdaptersCollection members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace