DataSource class

Office 2013 and later

Represents a data source in a form template.


Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract class DataSource

A DataSource object corresponds to one of the sources of stored data associated with an InfoPath form template. A DataSource object can represent either the form template's primary (main) data source, or a secondary data source obtained from some external source of data using an associated data connection (referred to as a data adapter in the first release of Microsoft InfoPath). Working with a form's main data source provides access to the underlying XML document of the form, whereas working with a secondary data source provides access to data retrieved from an external source of data such as a Web Service query.

The DataSource object provides properties and methods that can be used to programmatically interact with the stored data, as well as providing access to the associated data connection for secondary data sources. A DataSource object can be accessed using the DataSources property of the XmlForm class.

For secondary data sources, a DataSource object acts as an intermediary between the form and the data connection that is used to obtain data from an external data source, such as a connection to a Microsoft Access or Microsoft SQL Server database, an .xml file, or an XML Web service. The type of data connection object used depends on the type of external data connection used to acquire the data. The DataSource object provides a common set of properties and methods that can be used for all types of data connection objects, and each of the data connection objects provides its own set of properties and methods.

Microsoft InfoPath supports the following kinds of data connections:

  • A connection query or submit using ActiveX Data Objects (ADO) represented by the AdoQueryConnection and AdoSubmitConnection objects.

  • A connection to query or submit to an external data source that is registered in the Business Data Connectivity service (BDC) a server running SharePoint Foundation 2010 or SharePoint Server 2010 represented by the BdcQueryConnection or BdcSubmitConnection objects.

  • A connection to query or submit to a SharePoint list represented by the SharepointListRWQueryConnection or SharepointListRWSubmitConnection objects.

  • A connection to a Web service represented by the WebServiceConnection object.

  • A connection to query or submit to an XML file represented by the FileQueryConnection and FileSubmitConnection objects.

  • A connection to submit by e-mail represented by the EmailSubmitConnection object.

The DataSource class corresponds to the DataObject interface in the Microsoft InfoPath 2003 object model.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.