Export (0) Print
Expand All

ADOAdapter2.Query method

Reads data from the associated data adapter.

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

void Query()

The query fails if QueryAllowed is false.

Important noteImportant

This member 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.

In the following example, the Query method of the ADOAdapterObject object is used to query the Employees table of the Northwind database through the secondary data source "Employees." The EmployeeID of the record returned matches the value of the my:field2 node. This sample requires my:field2 in the main data source and bound to a text box in a view that contains the button to invoke the following code:

// retrieve the Employees Adapter from the DataAdapters collection
ADOAdapter employeesDA = (ADOAdapter)thisXDocument.DataAdapters["Employees"];
// get employee’s ID from the main DOM
string employeeID = thisXDocument.DOM.selectSingleNode("//my:field2").text;
// Change the ADOAdapter’s command to retrieve the record of the Employee’s ID entered
// by the user
employeesDA.Command="select * from Employees where EmployeeID=" + employeeID;
// get DataObject from the DataObjects collection and call Query to refresh
// the data object
DataObject employeesDO = thisXDocument.DataObjects["Employees"];
employeesDO.Query();
Show:
© 2014 Microsoft