ADOAdapter2.Command Property
Gets or sets the SQL command string text for an ADOAdapterObject object.
Namespace: Microsoft.Office.Interop.InfoPath
Assembly: Microsoft.Office.Interop.InfoPath (in Microsoft.Office.Interop.InfoPath.dll)
Syntax
'Declaration
Property Command As String
Get
Set
'Usage
Dim instance As ADOAdapter2
Dim value As String
value = instance.Command
instance.Command = value
string Command { get; set; }
Property Value
Type: System.String
Implements
Remarks
The Command property of the ADOAdapter object contains the SQL command text that is used by the ADO data adapter to submit data to and retrieve data from an ActiveX Data Objects/OLEDB external data source.
Note
The ADOAdapter object is limited to work only with Microsoft SQL Server and Microsoft Access databases.
Examples
In the following example, the Command property of the ADOAdapter 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 example requires my:field2 in the main data source and bound to a text box in a view that contains a 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();