DataAdaptersCollection Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains a data adapter object corresponding to each data connection used within a Microsoft InfoPath form.
public interface class DataAdaptersCollection : Microsoft::Office::Interop::InfoPath::DataAdapters
[System.Runtime.InteropServices.Guid("096CD692-0786-11D1-95FA-0080C78EE3BB")]
public interface DataAdaptersCollection : Microsoft.Office.Interop.InfoPath.DataAdapters
type DataAdaptersCollection = interface
interface DataAdapters
Public Interface DataAdaptersCollection
Implements DataAdapters
- Derived
- Attributes
- Implements
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.<span class="label">DataAdapters</span>["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:
<span class="label">DataAdapters</span> dataAdapters;
dataAdapters = thisXDocument.<span class="label">DataAdapters</span>;
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);
}
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
Properties
Count |
Gets the number of data adapters in DataAdaptersCollection collection. (Inherited from DataAdapters) |
Item[Object] |
Gets a reference to the specified data adapter object from the DataAdaptersCollection collection, based on position or name. (Inherited from DataAdapters) |
Methods
GetEnumerator() |
Gets an IEnumerator that iterates over all entries in the DataAdapters collection. (Inherited from DataAdapters) |