Show All

# query Element (dataObject Element)

Associates a data adapter with a data object.

## Type

`xsd:complexType`

## Parent Elements

Element | Description
--- | ---
dataObject | Defines a secondary data object that is used in a Microsoft Office InfoPath form.

## Child Elements

Element | Description
--- | ---
adoAdapter | (Optional element) Defines an ActiveX Data Objects (ADO) data adapter that retrieves data from an ADO data source for the specified data object.
webServiceAdapter | (Optional element) Defines a Web service data adapter that retrieves data from a Web service for the specified data object.
xmlFileAdapter | (Optional element) Defines an .xml file data adapter that retrieves data from an .xml file for the specified data object.
sharepointListAdapter | (Optional element) Contains the data adapter information to query a SharePoint list or library.

## Attributes

None.

## Definition

    <xsd:element name="query" >
      <xsd:complexType>
        <xsd:choice>
          <xsd:element ref="xsf:adoAdapter" />
          <xsd:element ref="xsf:webServiceAdapter" />
          <xsd:element ref="xsf:xmlFileAdapter" />
          <xsd:element ref="xsf:sharepointListAdapter" />
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>

## Remarks

Note This item is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Editions Service Pack 1 or later is not installed. Any form defined by a form definition file (.xsf) that includes this item cannot be opened in InfoPath when service pack features are disabled or unavailable.

## Example

The following is an example of the query element:

    <xsf:dataObjects>
     <xsf:dataObject
      name="EmployeeNames"
      schema="EmployeeNames.xsd"
      initOnLoad="yes">
      <xsf:query>
       <xsf:adoAdapter
        connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
        Password=&quot;&quot;;User ID=Admin;
        Data Source=infnwind.mdb;Mode=Share Deny None;
        Extended Properties=&quot;&quot;;..."
        commandText="select [EmployeeID],[LastName],[FirstName]
         from [Employees] as [Employees]"
        queryAllowed="yes"
        submitAllowed="yes">
       </xsf:adoAdapter>
      </xsf:query>
     </xsf:dataObject>
    </xsf:dataObjects>

©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