Gets or sets the SQL command string text for an AdoSubmitConnection object.
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
The Command property of the ADOSubmitConnection object contains the SQL command text that is used by the ADO data connection to submit data to an ActiveX Data Objects/OLEDB external data source.
An ADOSubmitConnection object can only exist when there is a corresponding ADOQueryConnection object, and the data connections represented by both objects share the same set of property values. Changing the value of this property for the ADOSubmitConnection object will also change the value of the same property for the corresponding ADOQueryConnection object.
The ADOSubmitConnection object is limited to work only with Microsoft SQL Server and Microsoft Access databases.
This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.
In the following example, the Command property of the AdoSubmitConnection class and the Execute method of the DataConnection class are used to query a table in a secondary data source named Employees. The query is executed against the data connection created in InfoPath design mode to the database that contains the Employees table, which is named "EmployeesSubmit".
First, the value entered by the user in the field my:EmpID is used to update the SQL command text using the Command property. Then, the Execute method is used to refresh the data retrieved by data connection, which updates the record displayed in a Repeating Table control which bound to the Employees table on the form. This example requires the my:EmpID field in the main data source bound to a Text Box control in a view that contains a Button control to invoke the following code.
Public Sub RefreshData_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs) ' Get the Employees connection from the ' DataConnections collection. Dim myAdoSubmitConnection As AdoSubmitConnection = _ DirectCast(Me.DataConnections("EmployeesSubmit"), _ AdoSubmitConnection) ' Get the employee's ID from the EmpID field in ' the main data source. Dim myNav As XPathNavigator = _ CreateNavigator().SelectSingleNode("/my:myFields/my:EmpID", _ NamespaceManager) Dim employeeID As String = myNav.InnerXml ' Change the SQL command for Employees connection to retrieve ' the record of the Employee's ID entered by the user. myAdoQueryConnection.Command = _ "select * from [Employees] where [EmployeeID] = " & employeeID ' Execute the updated command against the data connection to ' refresh the data. myAdoSubmitConnection.Execute() End Sub