既定の Execute メソッドをオーバーライドし、返されたデータを挿入する別の場所を指定できるようにします。
名前空間: Microsoft.Office.InfoPath
アセンブリ: Microsoft.Office.InfoPath (microsoft.office.infopath.dll 内)
構文
'宣言
Public MustOverride Sub Execute ( _
output As XPathNavigator _
)
'使用
Dim instance As SharepointListQueryConnection
Dim output As XPathNavigator
instance.Execute(output)
public abstract void Execute (
XPathNavigator output
)
パラメータ
- output
返されたデータを挿入するフォームのプライマリ データ ソースまたはセカンダリ データ ソースの XML ノードを指定する XPathNavigator。output パラメータとして XPathNavigator を渡すと、ローカル コンピュータの XML ファイルまたはメモリに保持されている System.Xml.XmlDocument へのデータの挿入を指定することもできます。
例外処理
例外の種類 | 条件 |
---|---|
クエリ操作が失敗しました。 |
|
このメソッドに渡されたパラメータは null です。 |
|
このメソッドに渡されたパラメータは有効ではありません。たとえば、型または形式が正しくありません。 |
コメント
output パラメータに null を設定すると、既定の Execute メソッドを使用するのと同じ効果があり、フォーム テンプレートで定義されている宣言の設定を使用してデータを返します。
このメンバは、現在開いているフォームと同じドメイン内で実行されているフォーム、またはドメインを越えたアクセス許可を付与されているフォームだけがアクセスできます。
この型またはメンバは、Microsoft Office InfoPath 2007 または 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 のメンバ
Microsoft.Office.InfoPath 名前空間