다음을 통해 공유


AdoSubmitConnection.Command 속성

AdoSubmitConnection 개체에 대한 SQL 명령 문자열 텍스트를 가져오거나 설정합니다.

네임스페이스:  Microsoft.Office.InfoPath
어셈블리:  Microsoft.Office.InfoPath(Microsoft.Office.InfoPath.dll)

구문

‘선언
Public MustOverride Property Command As String
    Get
    Set
‘사용 방법
Dim instance As AdoSubmitConnection
Dim value As String

value = instance.Command

instance.Command = value
public abstract string Command { get; set; }

속성 값

형식: System.String
데이터 연결에 대한 SQL 명령 텍스트입니다.

주의

ADOSubmitConnection 개체의 Command 속성은 ActiveX Data Objects/OLEDB 외부 데이터 원본에 데이터를 전송하기 위해 ADO 데이터 연결에서 사용하는 SQL 명령 텍스트를 포함합니다.

중요

ADOSubmitConnection 개체는 해당 ADOQueryConnection 개체가 있고 두 개체로 표시되는 데이터 연결이 동일한 속성 값 집합을 공유하는 경우에만 존재할 수 있습니다. ADOSubmitConnection 개체에 대한 이 속성 값을 변경하면 해당 ADOQueryConnection 개체에 대한 동일한 속성 값도 변경됩니다.

참고 사항참고 사항

ADOSubmitConnection 개체는 Microsoft SQL Server 및 Microsoft Access 데이터베이스에서만 사용할 수 있습니다.

이 멤버는 현재 열려 있는 양식과 같은 도메인에서 실행하는 양식 또는 도메인 간 권한이 부여된 양식에서만 액세스할 수 있습니다.

이 형식 또는 멤버는 Microsoft InfoPath Filer에서 연 양식에서 실행되는 코드에서만 액세스할 수 있습니다.

다음 예제에서는 AdoSubmitConnection 클래스의 Command 속성 및 DataConnection 클래스의 Execute 메서드를 사용하여 보조 데이터 원본에 있는 Employees라고 하는 테이블을 쿼리합니다. 이 쿼리는 InfoPath 디자인 모드에서 Employees 테이블을 포함하는 데이터베이스에 설정된 데이터 연결에 대해 수행되며 이 쿼리의 이름은 "EmployeesSubmit"으로 지정됩니다.

먼저 사용자가 my:EmpID 필드에 입력한 값을 사용하여 Command 속성을 통해 SQL 명령 텍스트를 업데이트합니다. 그런 다음 Execute 메서드를 사용하여 데이터 연결에서 검색한 데이터를 새로 고칩니다. 이렇게 하면 양식의 Employees 테이블에 바인딩된 반복 표 컨트롤에 표시되는 레코드가 업데이트됩니다. 이 예제에서는 Button 컨트롤을 포함하는 보기에서 텍스트 상자 컨트롤에 바인딩되어 있는 기본 데이터 원본의 my:EmpID 필드가 다음 코드를 호출해야 합니다.

public void RefreshData_Clicked(object sender, ClickedEventArgs e)
{
   // Get the Employees connection from the 
   // DataConnections collection.
   AdoSubmitConnection myAdoSubmitConnection =
      (AdoSubmitConnection)(this.DataConnections["EmployeesSubmit"]);

   // Get the employee's ID from the EmpID field in 
   // the main data source.
   XPathNavigator myNav = 
      CreateNavigator().SelectSingleNode("/my:myFields/my:EmpID", 
      NamespaceManager);
   // Assign the value from the field to a variable.
   string employeeID = myNav.InnerXml;

   // Change the SQL command for Employees connection to retrieve 
   // the record of the Employee's ID entered by the user.
   myAdoSubmitConnection.Command = 
      "select * from [Employees] where [EmployeeID] = " + employeeID;

   // Execute the updated command against the data connection to 
   // refresh the data.
   myAdoSubmitConnection.Execute();
}
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

참고 항목

참조

AdoSubmitConnection 클래스

AdoSubmitConnection 멤버

Microsoft.Office.InfoPath 네임스페이스