Edit

Share via


SharePointListRWQueryConnection Class

Definition

Represents a data connection for retrieving data from a SharePoint list or document library.

public ref class SharePointListRWQueryConnection abstract : Microsoft::Office::InfoPath::DataConnection
public abstract class SharePointListRWQueryConnection : Microsoft.Office.InfoPath.DataConnection
type SharePointListRWQueryConnection = class
    inherit DataConnection
Public MustInherit Class SharePointListRWQueryConnection
Inherits DataConnection
Inheritance
SharePointListRWQueryConnection

Examples

In the following code example, a data connection named "Contacts", which connects to a list of contact information on a SharePoint site, is accessed by using the following two-step process. The name "Contacts" is passed to the Item[String] property of the DataConnectionCollection class to retrieve an object that represents the data connection. Then, the object returned from the collection is cast to the SharePointListRWQueryConnection type.

SharePointListRWQueryConnection spConnection = (SharePointListRWQueryConnection)this.DataConnections["Contacts"];
Dim spConnection As SharePointListRWQueryConnection = _
   DirectCast(Me.DataConnections("Contacts"), _
   SharePointListRWQueryConnection)

After the reference to the data connection has been set, you can use the properties or methods of the SharePointListRWQueryConnection object. The following code example sets a string variable to the value returned by the Name property inherited from the DataConnection base class.

string spName = spConnection.Name; Dim spName As String = spConnection.Name

Remarks

The SharePointListRWQueryConnection class represents a secondary data connection created in InfoPath that specifies all the information necessary for retrieving data from a SharePoint list or document library. To create a form template that contains a secondary data connection to a SharePoint list or document library, use the Data Connections command on the Data tab.

Note: Code written with the members of the SharePointListRWQueryConnection class is not compatible with a data connection to a SharePoint list or document library created in InfoPath 2003 or InfoPath 2007, with a data connection in a new form template created in InfoPath with one of the InfoPath 2007 Form Templates, or with a data connection converted with the Convert to Previous Version button in the Data Connections dialog box. If you do not need to maintain compatibility with an earlier version of InfoPath and want to write code with members of the SharePointListRWQueryConnection class, convert the data connection with the Convert to Current Version button in the Data Connections dialog box.

Note: You can create a primary (main) data connection to a SharePoint list by creating a new form template with the SharePoint List template. However, it is not possible to write form code behind such a form, because only declarative logic, such as rules, is supported in a form template created with the SharePoint List template. For this reason, you cannot use the SharePointListRWQueryConnection class and its members to work with a primary data connection to a SharePoint list.

The SharePointListRWQueryConnection class provides properties that can be used to get the name of the data connection and the URL of the list or document library on the SharePoint Foundation or Microsoft SharePoint Server site from which the connection retrieves data.

The SharePointListRWQueryConnection object associated with the data connection is accessible by using the DataConnections property of the XmlForm class to return the connection from the DataConnectionCollection of the form template.

The default Execute() method, inherited from the DataConnection base class, performs a query or submit operation using the values that were declaratively defined in the InfoPath form template at design time. Additionally, the SharePointListRWQueryConnection class provides the Execute(XPathNavigator) method, which enables you to specify a different location to insert the data that is returned.

Constructors

SharePointListRWQueryConnection()

Properties

ContentTypeId

Gets or sets the content type ID of the SharePoint list associated with the SharePointListRWQueryConnection object.

ListId

Gets or sets the list ID of the SharePoint list associated with the SharePointListRWQueryConnection object.

Name

Gets the name of the data connection.

(Inherited from DataConnection)
SiteUrl

Gets or sets a Uri object that represents the URL of the SharePoint Foundation site associated with the Microsoft.Office.InfoPath.SharepointListRWQueryConnection object.

Methods

Execute()

Depending on which ConnectionTypeConnection class it is called from, executes a submit or query operation on the data connection using the declaratively defined values for the submitted data, query parameters, or data to retrieve.

(Inherited from DataConnection)
Execute(XPathNavigator)

Overrides the default Execute() method to enable specifying a different location to insert the data that is returned.

Applies to