Language

DataConnection.Execute メソッド

定義

どの ConnectionTypeConnection クラスから呼び出されたかに応じて、送信されるデータ、クエリ パラメーター、または取得するデータに対して宣言的に定義された値を使用して、データ接続で送信操作またはクエリ操作を実行します。

public:
 abstract void Execute();
public abstract void Execute();
abstract member Execute : unit -> unit
Public MustOverride Sub Execute ()

例外

実行操作が失敗しました。

このメソッドに渡されるパラメーターは null 参照です (Visual Basic では Nothing)。

このメソッドに渡されたパラメーターは有効ではありません。 たとえば、型または形式が正しくありません。

送信操作の Execute() 場合、メソッドはイベントのイベント ハンドラー Loading から呼び出されました。

構造化例外ハンドラー (SEH) のエラーが、相当するマネージ コードの例外にマップされていないアンマネージ コードからスローされました。 詳細については、MSDN ライブラリで「アンマネージ例外」および「構造化例外処理」を検索してください。

例

次の例では、ADOQueryConnection クラスの Command プロパティを使用してデータ接続の SQL コマンド テキストを更新した後、クラスの DataConnectionExecute メソッドを使用してクエリを実行し、フォーム内のデータを更新します。

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

   // 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.
   myAdoQueryConnection.Command = 
      "select * from [Employees] where [EmployeeID] = " + employeeID;

   // Execute the updated command against the data connection to 
   // refresh the data.
   myAdoQueryConnection.Execute();
}
Public Sub RefreshData_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
   ' Get the Employees connection from the 
   ' DataConnections collection.
   Dim myAdoQueryConnection As AdoQueryConnection = _
      DirectCast(Me.DataConnections("Employees"), AdoQueryConnection)

   ' 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.
    myAdoQueryConnection.Execute()
End Sub

注釈

フォーム テンプレートを設計するときは、[データ] タブの [アクションの送信] コマンドを使用して、送信先と、フォーム テンプレート ファイルのソリューション定義ファイル (.xsf) に格納されている関連設定を定義できます。 [データ] タブの [データConnections] コマンドを使用して、ソリューション定義ファイル (.xsf) に格納されるデータの送信または受信の設定を定義することもできます。 メソッドを Execute() 使用すると、これらの宣言的に定義された設定を使用して、データ接続に対して送信操作またはクエリ操作が実行されます。

DataConnection.Execute メソッドは、データ接続を表すすべてのクラスによって継承され、EmailSubmitConnection.Execute() メソッドなどのように、そのクラスの継承されたメソッドとして公開されます。 継承しているクラスが表すデータ接続の種類に応じて、Execute メソッドは、その接続に適した宣言されている送信操作またはクエリ操作を実行します。

AdoQueryConnection クエリ
AdoSubmitConnection 送信
BdcQueryConnection クエリ
BdcSubmitConnection 送信
EmailSubmitConnection 送信
FileQueryConnection クエリ
FileSubmitConnection 送信
SharePointListRWQueryConnection注: 以前の SharepointListQueryConnection バージョンの InfoPath で使用されていたクラスは非推奨になりました。クエリ
WebServiceConnection 送信またはクエリ

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

この型またはメンバーには、Microsoft InfoPath Filler または Web ブラウザーで開いたフォームで実行されるコードからアクセスできます。

適用対象