DataConnection.Execute メソッド

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

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

構文

'宣言
Public MustOverride Sub Execute
'使用
Dim instance As DataConnection

instance.Execute()
public abstract void Execute()

例外

例外 条件
WebException

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

ArgumentNullException

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

ArgumentException

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

InvalidOperationException

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

SEHException

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

解説

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

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

クラス

操作

AdoQueryConnection

クエリ

AdoSubmitConnection

送信

BdcQueryConnection

クエリ

BdcSubmitConnection

送信

EmailSubmitConnection

送信

FileQueryConnection

クエリ

FileSubmitConnection

送信

SharePointListRWQueryConnection

メモメモ
InfoPath の以前のバージョンで使用されていた SharepointListQueryConnection クラスは現在使用されていません。

クエリ

WebServiceConnection

送信またはクエリ

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

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

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

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

関連項目

参照

DataConnection クラス

DataConnection メンバー

Microsoft.Office.InfoPath 名前空間