Partager via


SharePointListRWQueryConnection.Execute(XPathNavigator) Méthode

Définition

Remplace la méthode par défaut Execute() pour activer 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. Passé XPathNavigator 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 XmlDocument élément conservé en mémoire.

Exceptions

L'opération de requête a échoué.

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 de code suivant, la Execute(XPathNavigator) méthode de la Microsoft.Office.InfoPath.SharepointListRWQueryConnection classe est utilisée pour exécuter une requête sur la connexion « Contacts » et stocker la sortie dans un XmlDocument qui est créé en mémoire. Il affiche ensuite la sortie stockée dans dans XmlDocument le 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 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

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 par défaut Execute() 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.

S’applique à