Show All

# QueryAdapter Property (XDocument Object)

A read-only property that returns a reference to the data adapter object that is associated with a Microsoft Office InfoPath 2003 form.

expression.QueryAdapter

expression Required. An expression that returns a reference to an XDocument object.

## Security Level

2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

## Remarks

Data adapter objects provide different properties and methods that retrieve and submit data to external data sources; the data adapter that is associated with a form is dependent on the type of data source that was used when the form was initially created.

The QueryAdapter property allows you to access an InfoPath form's primary data source. To access the data adapter objects used for a form's secondary data sources, use the DataObjects property of the XDocument object.

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.

Note The XMLFileAdapter object cannot be used with the QueryAdapter property of the XDocument object, it is only used for secondary data sources. To access a form's underlying XML document, use the DOM property of the XDocument object.

## Example

In the following example, the QueryAdapter property of the XDocument object is used to set a reference to the ADOAdapter data adapter object; then the Command property of the ADOAdapter object is used to display the SQL command text in a message box:

    var objADOAdapter;

    objADOAdapter = XDocument.QueryAdapter;
    XDocument.UI.Alert("SQL command text: " + objADOAdapter.Command);

©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