ADOAdapter2.Command 属性

定义

获取或设置 对象的 SQL 命令字符串文本 ADOAdapterObject

public:
 property System::String ^ Command { System::String ^ get(); void set(System::String ^ value); };
public string Command { get; set; }
member this.Command : string with get, set
Public Property Command As String

属性值

实现

示例

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

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

注解

ADOAdapter 对象的 Command 属性包含 SQL 命令文本,ADO 数据适配器使用该文本向 ActiveX 数据对象/OLEDB 外部数据源提交数据以及从该数据源检索数据。

注意ADOAdapter 对象仅限于 Microsoft SQL Server 和 Microsoft Access 数据库。

重要提示:此成员只能由与当前打开的窗体在同一域中运行的表单访问,或者由已授予跨域权限的表单访问。

适用于