Share via


(XPathNavigator) del método SharePointListRWQueryConnection.Execute

Invalida al método predeterminado Execute para habilitar la especificación de una ubicación diferente para insertar los datos devueltos.

Espacio de nombres:  Microsoft.Office.InfoPath
Ensamblado:  Microsoft.Office.InfoPath (en Microsoft.Office.InfoPath.dll)

Sintaxis

'Declaración
Public MustOverride Sub Execute ( _
    output As XPathNavigator _
)
'Uso
Dim instance As SharePointListRWQueryConnection
Dim output As XPathNavigator

instance.Execute(output)
public abstract void Execute(
    XPathNavigator output
)

Parámetros

  • output
    Tipo: System.Xml.XPath.XPathNavigator

    Objeto XPathNavigator que especifica un nodo XML en el origen de datos principal o secundario del formulario para insertar los datos devueltos en éste. El objeto XPathNavigator que se pasa como el parámetro output también puede especificar que se inserten datos en cualquier archivo XML en el equipo local o en un objeto XmlDocument almacenado en la memoria.

Excepciones

Excepción Condición
WebException

Error en la operación de consulta.

ArgumentNullException

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

ArgumentException

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

Comentarios

Si se establece el parámetro output en una referencia null (Nothing en Visual Basic) el resultado es el mismo que si se usa 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.

Ejemplos

En el siguiente ejemplo de código, se usa el método Execute(XPathNavigator) de la clase SharepointListRWQueryConnection para ejecutar una consulta en la conexión "Contacts" y almacenar el resultado en un XmlDocument que se crea en la memoria. Posteriormente, éste muestra el resultado almacenado en el XmlDocument del 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 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

Vea también

Referencia

clase SharePointListRWQueryConnection

Miembros SharePointListRWQueryConnection

Sobrecarga Execute

Espacio de nombres Microsoft.Office.InfoPath