Compartir a través de


SharepointListQueryConnection.Execute(XPathNavigator) Método

Definición

Invalida el método predeterminado Execute() para permitir especificar una ubicación diferente para insertar los datos que se devuelven.

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)

Parámetros

output
XPathNavigator

que XPathNavigator especifica un nodo XML en el origen de datos principal o secundario del formulario en el que se van a insertar los datos devueltos. El XPathNavigator pasado como output parámetro también puede especificar para insertar los datos en cualquier archivo XML en el equipo local o en un System.Xml. XmlDocument contenido en memoria.

Excepciones

La operación de consulta produjo un error o no devolvió ningún dato (la lista consultada está vacía).

El parámetro pasado a este método es una referencia nula (Nothing en Visual Basic).

El parámetro que se ha pasado a este método no es válido. Por ejemplo, es de un tipo o formato no válido.

Ejemplos

En el ejemplo siguiente, el método Execute(output) de la SharepointListQueryConnection clase se usa para ejecutar una consulta en la conexión "Contacts" y almacenar la salida en un XmlDocument que se crea en memoria. A continuación, se muestra el resultado guardado en XmlDocument en el campo QueryOutput del formulario.

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

Comentarios

Establecer el output parámetro en una referencia nula (Nothing en Visual Basic) tiene el mismo efecto que usar el método Execute predeterminado para devolver datos mediante la configuración declarativa definida en la plantilla de formulario.

Únicamente se puede acceder a este miembro con formularios que se ejecuten en el mismo dominio que el formulario que está actualmente abierto o con formularios a los que se hayan concedido permisos entre dominios.

Se puede acceder a este tipo o miembro desde el código que se ejecuta en los formularios abiertos en Microsoft InfoPath Filler o en un explorador web.

Se aplica a