Modifica

Condividi tramite


ADOAdapter2.Query Method

Definition

Reads data from the associated data adapter.

public:
 void Query();
public void Query ();
abstract member Query : unit -> unit
Public Sub Query ()

Examples

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.<span class="label">Query</span>();

Remarks

The query fails if QueryAllowed is false.

Applies to