AdoSubmitConnection.Command プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オブジェクトの SQL コマンド文字列テキストを AdoSubmitConnection 取得または設定します。
public:
abstract property System::String ^ Command { System::String ^ get(); void set(System::String ^ value); };
public abstract string Command { get; set; }
member this.Command : string with get, set
Public MustOverride Property Command As String
プロパティ値
データ接続の SQL コマンド文字列。
例
次の例では、AdoSubmitConnection クラスの Command プロパティと クラスのメソッドをExecute()DataConnection使用して、Employees という名前のセカンダリ データ ソース内のテーブルに対してクエリを実行します。 クエリは、Employees テーブルを含むデータベースを対象にして InfoPath デザイン モードで作成されたデータ接続 ("EmployeesSubmit") に対して実行されます。
まず、ユーザーがフィールド my:EmpID に入力した値を使用して、 Command プロパティを使用して SQL コマンド テキストを更新します。 次に、 Execute メソッドを使用して、データ接続によって取得されたデータを更新します。これにより、フォーム上の Employees テーブルにバインドされた繰り返しテーブル コントロールに表示されるレコードが更新されます。 この例では、次のコードを呼び出すために、Button コントロールを含むビューの Text Box コントロールにバインドされたメイン データ ソースの 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 オブジェクトの Command プロパティは、ActiveX Data Objects/OLEDB 外部データ ソースにデータを送信するために ADO データ接続によって使用される SQL コマンド テキストを含みます。
重要: ADOSubmitConnection オブジェクトは、対応する ADOQueryConnection オブジェクトがあり、両方のオブジェクトで表されるデータ接続が同じプロパティ値のセットを共有している場合にのみ存在できます。 ADOSubmitConnection オブジェクトのこのプロパティの値を変更すると、対応する ADOQueryConnection オブジェクトの同じプロパティの値も変更されます。
注: ADOSubmitConnection オブジェクトは、Microsoft SQL Server および Microsoft Access データベースでのみ動作するように制限されています。
このメンバは、現在開いているフォームと同じドメインで実行中のフォーム、またはクロスドメインのアクセス許可が与えられたフォームだけがアクセスできます。
この型またはメンバーには、Microsoft InfoPath Filler で開いたフォームで実行されるコードからのみアクセスできます。