ADOAdapter2.Query 方法

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

命名空间:  Microsoft.Office.Interop.InfoPath.SemiTrust
程序集:  Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)

语法

声明
Sub Query
用法
Dim instance As ADOAdapter2

instance.Query()
void Query()

备注

如果 QueryAllowed 为 false,则查询失败。

重要

此成员只能由与当前打开的表单在相同域中运行的表单访问,或者由已授予跨域权限的表单访问。

示例

在以下示例中,ADOAdapterObject 对象的 Query 方法用于通过辅助数据源"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.Query();

另请参阅

引用

ADOAdapter2 接口

ADOAdapter2 成员

Microsoft.Office.Interop.InfoPath.SemiTrust 命名空间