SharepointListQueryConnection.Execute(XPathNavigator) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Remplace la méthode par défaut Execute() pour permettre la spécification d’un autre emplacement pour insérer les données retournées.
public:
abstract void Execute(System::Xml::XPath::XPathNavigator ^ output);
public abstract void Execute (System.Xml.XPath.XPathNavigator output);
override this.Execute : System.Xml.XPath.XPathNavigator -> unit
Public MustOverride Sub Execute (output As XPathNavigator)
Paramètres
- output
- XPathNavigator
XPathNavigator qui spécifie un nœud XML dans la source de données primaire ou secondaire du formulaire dans lequel insérer les données retournées. Le XPathNavigator passé en tant que output
paramètre peut également spécifier d’insérer les données dans n’importe quel fichier XML sur l’ordinateur local ou dans un System.Xml. XmlDocument conservé en mémoire.
Exceptions
The query operation failed or returned no data (the queried list is empty).
Le paramètre passé à cette méthode est une référence null (Nothing en Visual Basic).
Le paramètre passé à cette méthode n'est pas valide. Par exemple, le type ou le format est incorrect.
Exemples
Dans l’exemple suivant, la méthode Execute(output
) de la SharepointListQueryConnection classe est utilisée pour exécuter une requête sur la connexion « Contacts » et stocker la sortie dans un XmlDocument créé en mémoire. Elle affiche ensuite le résultat stocké dans le XmlDocument du champ QueryOutput du formulaire.
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
Remarques
Définir le output
paramètre sur une référence null (Nothing en Visual Basic) a le même effet que l’utilisation de la méthode Execute par défaut pour retourner des données à l’aide des paramètres déclaratifs définis dans le modèle de formulaire.
Seuls les formulaires qui s’exécutent dans le même domaine que le formulaire actuellement ouvert ou les formulaires disposant d’autorisations inter-domaines peuvent accéder à ce membre.
Vous pouvez accéder à ce type ou à ce membre à partir du code exécuté dans les formulaires ouverts dans Microsoft InfoPath Filler ou dans un navigateur web.