次の方法で共有


AdoSubmitConnection.Command プロパティ

AdoSubmitConnection オブジェクトの SQL コマンド文字列を取得または設定します。

名前空間: Microsoft.Office.InfoPath
アセンブリ: Microsoft.Office.InfoPath (microsoft.office.infopath.dll 内)

構文

'宣言
Public MustOverride Property Command As String
'使用
Dim instance As AdoSubmitConnection
Dim value As String

value = instance.Command

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

プロパティ値

データ接続の SQL コマンド文字列。

コメント

ADOSubmitConnection オブジェクトの Command プロパティは、ActiveX Data Objects/OLEDB 外部データ ソースにデータを送信するために ADO データ接続によって使用される SQL コマンド テキストを含みます。

メモ重要 :

ADOSubmitConnection オブジェクトが存在できるのは、対応する ADOQueryConnection オブジェクトがあり、両方のオブジェクトで表されるデータ接続で、同じプロパティ値のセットを共有している場合のみです。ADOSubmitConnection オブジェクトのこのプロパティの値を変更すると、対応する ADOQueryConnection オブジェクトの同じプロパティの値も変更されます。

メモメモ :

ADOSubmitConnection オブジェクトが機能するのは、Microsoft SQL Server および Microsoft Access データベースのみに限定されています。

このメンバは、現在開いているフォームと同じドメイン内で実行されているフォーム、またはドメインを越えたアクセス許可を付与されているフォームだけがアクセスできます。

この型またはメンバは、Microsoft Office InfoPath 2007 で開いているフォームで実行されているコードからのみアクセスできます。

次の例では、AdoSubmitConnection クラスの Command プロパティおよび DataConnection クラスの Execute メソッドは、Employees という名前のセカンダリ データ ソースのテーブルをクエリするために使用されます。クエリは、Employees テーブルを含むデータベースを対象にして InfoPath デザイン モードで作成されたデータ接続 ("EmployeesSubmit") に対して実行されます。

最初に、my:EmpID フィールドでユーザーが入力した値が、Command プロパティを使って SQL コマンド テキストを更新するために使用されます。次に、Execute メソッドを使用して、データ接続で取得されたデータを更新し、これにより、フォームの Employees テーブルにバインドされた [繰り返しテーブル] コントロールに表示されるレコードが更新されます。この例では、次のコードを起動するために、[ボタン] コントロールを含むビューで [テキスト ボックス] コントロールにバインドされたメイン データ ソースに、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 名前空間