次の方法で共有


SharepointListQueryConnection.Execute メソッド (XPathNavigator)

メモ: この API は現在は使用されていません。

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

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

構文

'宣言
<ObsoleteAttribute("The SharePointListQueryConnection class has been deprecated. Use SharePointListRWQueryConnection instead.")> _
Public MustOverride Sub Execute ( _
    output As XPathNavigator _
)
'使用
Dim instance As SharepointListQueryConnection
Dim output As XPathNavigator

instance.Execute(output)
[ObsoleteAttribute("The SharePointListQueryConnection class has been deprecated. Use SharePointListRWQueryConnection instead.")]
public abstract void Execute(
    XPathNavigator output
)

パラメーター

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

例外

例外 条件
WebException

クエリ操作が失敗したか、あるいはデータを返しませんでした (クエリ操作が行われたリストは空です)。

ArgumentNullException

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

ArgumentException

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

解説

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

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

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

次の例では、SharepointListQueryConnection クラスの Execute(output) メソッドを使用して、"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 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 
   // SharepointListQueryConnection and log the results
   // in the XmlDocument created above.
    SharepointListQueryConnection queryConnection = 
      (SharepointListQueryConnection)(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 XmlDocument object. When
   ' creating a more complex document, use 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 
   ' SharepointListQueryConnection and log the results
   '  in the XmlDocument created above.
    Dim myQueryConnection As SharepointListQueryConnection  = _
      DirectCast(DataConnections["Contacts"], _
      SharepointListQueryConnection)
    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

関連項目

参照

SharepointListQueryConnection クラス

SharepointListQueryConnection メンバー

Execute オーバーロード

Microsoft.Office.InfoPath 名前空間