Поделиться через


SharePointListRWQueryConnection.Execute(XPathNavigator) Метод

Определение

Переопределяет метод по умолчанию Execute() , чтобы включить указание другого расположения для вставки возвращаемых данных.

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)

Параметры

output
XPathNavigator

Объект XPathNavigator , указывающий XML-узел в первичном или вторичном источнике данных формы, в которую нужно вставить возвращенные данные. Переданный XPathNavigator в output качестве параметра также может указать для вставки данных в любой XML-файл на локальном компьютере или в хранящиеся XmlDocument в памяти.

Исключения

Не удалось завершить операцию запроса.

Параметр, передаваемый этому методу, является пустой ссылкой (Nothing в Visual Basic).

Этому методу передан недопустимый параметр. Например, неправильный тип или формат.

Примеры

В следующем примере Execute(XPathNavigator) кода метод Microsoft.Office.InfoPath.SharepointListRWQueryConnection класса используется для выполнения запроса к подключению "Контакты" и сохранения выходных данных в созданном XmlDocument в памяти. Затем в поле QueryOutput формы отображаются выходные данные, хранящиеся в XmlDocument объекте .

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

Комментарии

output Установка для параметра пустой ссылки (Nothing в Visual Basic) имеет тот же эффект, что и использование метода по умолчанию Execute() для возврата данных с помощью декларативных параметров, определенных в шаблоне формы.

Доступ к этому элементу предоставляется только формам, работающим в том же домене, что и текущая открытая форма, а также формам с междоменными правами доступа.

Доступ к этому типу или элементу предоставляется только из кода, выполняющегося в формах, открытых в Microsoft InfoPath Filler или браузере.

Применяется к