次の方法で共有


SharePointListRWQueryConnection.Execute メソッド (XPathNavigator)

既定の Execute メソッドをオーバーライドし、返されたデータを挿入する別の場所を指定できるようにします。

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

構文

'宣言
Public MustOverride Sub Execute ( _
    output As XPathNavigator _
)
'使用
Dim instance As SharePointListRWQueryConnection
Dim output As XPathNavigator

instance.Execute(output)
public abstract void Execute(
    XPathNavigator output
)

パラメーター

  • output
    型: System.Xml.XPath.XPathNavigator
    返されたデータを挿入する、フォームのプライマリ データ ソースまたはセカンダリ データ ソースの XML ノードを指定する XPathNavigator。output パラメーターとして渡される XPathNavigator では、ローカル コンピューター上の任意の XML ファイル、またはメモリに保持されている XmlDocument にデータを挿入するように指定することもできます。

例外

例外 条件
WebException

クエリ操作が失敗しました。

ArgumentNullException

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

ArgumentException

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

解説

output パラメーターを null 参照 (Visual Basic ではNothing ) に設定することは、既定の Execute メソッドを使用して、フォーム テンプレートに定義されている宣言設定によりデータを返すのと同じ効果があります。

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

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

次のコード例では、SharepointListRWQueryConnection クラスの Execute(XPathNavigator) メソッドを使用して、"Contacts" 接続に対するクエリを実行し、メモリに作成される XmlDocument に出力を格納します。次に、XmlDocument に格納された出力を、フォームの "QueryOutput" フィールドに表示します。

public void ExecuteOutput_Clicked(object sender, ClickedEventArgs e)
{
   // Create the XmlDocument to accept the query results.
   XmlDocument outputFile = new XmlDocument();
   outputFile.LoadXml(
      "<?xml version=\"1.0\" encoding=\"utf-8\" ?><outputRoot></outputRoot>");

   // Create XmlNamespaceManager for XmlDocument object. When
   // creating a more complex document, use the AddNamespace method
   // to add a mapping from namespace prefix to namespace URL for 
   // each namespace to this object.
   XmlNamespaceManager outputFileNamespaceManager = 
      new XmlNamespaceManager(outputFile.NameTable);

   // Create an XPathNavigator positioned at the root of the
   // XmlDocument output file created above.
   XPathNavigator outputFileNavigator = outputFile.CreateNavigator();
   XPathNavigator outputRootNavigator = 
      outputFileNavigator.SelectSingleNode("/outputRoot", 
      outputFileNamespaceManager);

   // Query the SharePoint list defined for the 
   // SharepointListRWQueryConnection and log the results
   // in the XmlDocument created above.
    SharepointListRWQueryConnection queryConnection = 
      (SharepointListRWQueryConnection)(DataConnections["Contacts"]);
    queryConnection.Execute(outputRootNavigator);

   // Insert the results of the query from the XmlDocument in the 
   // QueryOutput field of the main data source of the form.
   XPathNavigator mainNavigator = MainDataSource.CreateNavigator();
   XPathNavigator queryOutputNavigator = 
      mainNavigator.SelectSingleNode("/my:myFields/my:QueryOutput",
      NamespaceManager);
    queryOutputNavigator.SetValue(outputRootNavigator.InnerXml);
}
Public Sub ExecuteOutput_Clicked(ByVal sender As Object , _
   ByVal e As ClickedEventArgs)
{
   ' Create the XmlDocument to accept the query results.
   Dim outputFile As XmlDocument = new XmlDocument()
   outputFile.LoadXml(
      "<?xml version=\"1.0\" encoding=\"utf-8\" ?><outputRoot></outputRoot>")

   ' Create XmlNamespaceManager for the XmlDocument object. When
   ' creating a more complex document, use the AddNamespace method
   ' to add a mapping from namespace prefix to namespace URL for 
   ' each namespace to this object.
   Dim outputFileNamespaceManager As XmlNamespaceManager  = _
      new XmlNamespaceManager(outputFile.NameTable)

   ' Create an XPathNavigator positioned at the root of the
   ' XmlDocument output file created above.
   Dim outputFileNavigator As XPathNavigator = _
      outputFile.CreateNavigator()
   Dim outputRootNavigator As XPathNavigator = 
      outputFileNavigator.SelectSingleNode("/outputRoot", 
      outputFileNamespaceManager)

   ' Query the SharePoint list defined for the 
   ' SharepointListRWQueryConnection and log the results
   '  in the XmlDocument created above.
    Dim myQueryConnection As SharepointListRWQueryConnection  = _
      DirectCast(DataConnections["Contacts"], _
      SharepointListRWQueryConnection)
    myQueryConnection.Execute(outputRootNavigator);

   ' Insert the results of the query from the XmlDocument 
   ' in the QueryOutput field of the main data source of the form.
   Dim mainNavigator As XPathNavigator  = _
      MainDataSource.CreateNavigator()
   Dim queryOutputNavigator As XPathNavigator  = 
      mainNavigator.SelectSingleNode("/my:myFields/my:QueryOutput", _
      NamespaceManager)
    queryOutputNavigator.SetValue(outputRootNavigator.InnerXml)
End Sub

関連項目

参照

SharePointListRWQueryConnection クラス

SharePointListRWQueryConnection メンバー

Execute オーバーロード

Microsoft.Office.InfoPath 名前空間