ADOAdapter2.Query 方法

定义

从关联的数据适配器中读取数据。

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

示例

在以下示例中,对象的 Query 方法 ADOAdapterObject 用于通过辅助数据源“Employees”查询 Northwind 数据库的 Employees 表。 EmployeeID返回的记录的 与节点的值my:field2匹配。 此示例要求 my:field2 在主数据源中绑定到视图中的文本框,该视图中包含 用于调用以下代码的按钮:

// 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>();

注解

如果 QueryAllowedfalse,则查询失败。

适用于