DataSource.Name property

Office 2013 and later

Gets the name of the associated DataSource object.

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

Public MustOverride ReadOnly Property Name As String
Dim instance As DataSource
Dim value As String

value = instance.Name

Property value

Type: System.String
If the DataSource object represents a secondary data source, returns the name of the data source. If the DataSource object represents the primary (main) data source, returns String.Empty.

If the data source is a secondary data source, the name of the DataSource object is the same as the name of the data source that it represents. For secondary data sources, the name of the DataSource object can also be used as the argument to the Item() property of the DataConnectionCollection class.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

In the following example, the name of each DataSource object in the DataSourceCollection is displayed in a message box.

For Each source As DataSource In Me.DataSources
   MessageBox.Show("Source name: " & source.Name)