Assembly: Microsoft.Office.Interop.InfoPath.SemiTrust (in microsoft.office.interop.infopath.semitrust.dll)
The query fails if QueryAllowed is false.
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();