Edit

Share via


DataConnectionCollection.Item[] Property

Definition

Overloads

Item[Int32]

Gets a reference to the specified DataConnection object from the collection by index value.

Item[String]

Gets a reference to the specified DataConnection object from the collection by name.

Item[Int32]

Gets a reference to the specified DataConnection object from the collection by index value.

public:
 abstract property Microsoft::Office::InfoPath::DataConnection ^ default[int] { Microsoft::Office::InfoPath::DataConnection ^ get(int index); };
public abstract Microsoft.Office.InfoPath.DataConnection this[int index] { get; }
member this.Item(int) : Microsoft.Office.InfoPath.DataConnection
Default Public MustOverride ReadOnly Property Item(index As Integer) As DataConnection

Parameters

index
Int32

The zero-based index of the DataConnection object to get.

Property Value

The specified object.

Examples

In the following example, the first DataConnection object is retrieved from the DataConnectionCollection, and then cast to the EmailSubmitConnection type.

// Get the first connection from the 
// DataConnections collection.
EmailSubmitConnection myEmailSubmitConnection =
   (EmailSubmitConnection)(this.DataConnections[0]);
' Get the first connection from the 
' DataConnections collection.
Dim myEmailSubmitConnection As EmailSubmitConnection = _
   DirectCast(Me.DataConnections(0), EmailSubmitConnection)

Remarks

After you have set a reference to the DataConnection object that the Item property returns, you can access any of its properties or methods after the object has been cast to the appropriate type for the corresponding data connection. For example, to access the properties and methods of a data connection for submitting a form in e-mail, you must cast the returned DataConnection object to the EmailSubmitConnection type.

Important: Index value of a given data connection is not guaranteed to be the same between versions, or between sessions of opening the same form template in InfoPath and in a Web browser (from an appropriately configured document library on SharePoint Server 2010 running InfoPath Forms Services). To reliably open the same data connection under all conditions, you should open the data connection explicitly by name using the Item[String] method instead.

This member can be accessed without restrictions.

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

Applies to

Item[String]

Gets a reference to the specified DataConnection object from the collection by name.

public:
 abstract property Microsoft::Office::InfoPath::DataConnection ^ default[System::String ^] { Microsoft::Office::InfoPath::DataConnection ^ get(System::String ^ name); };
public abstract Microsoft.Office.InfoPath.DataConnection this[string name] { get; }
member this.Item(string) : Microsoft.Office.InfoPath.DataConnection
Default Public MustOverride ReadOnly Property Item(name As String) As DataConnection

Parameters

name
String

The name of the DataConnection object to get.

Property Value

The specified object.

Examples

In the following example, the DataConnection object named "Employees" is retrieved from the DataConnectionCollection, and then cast to the AdoQueryConnection type (which represents a data connection for retrieving data from an Access or SQL Server database).

// Get the Employees connection from the 
// DataConnections collection.
AdoQueryConnection myAdoQueryConnection =
   (AdoQueryConnection)(this.DataConnections["Employees"]);
' Get the Employees connection from the 
' DataConnections collection.
Dim myAdoQueryConnection As AdoQueryConnection = _
   DirectCast(Me.DataConnections("Employees"), AdoQueryConnection)

Remarks

After you have set a reference to the DataConnection object that the Item property returns, you can access any of its properties or methods after the object has been cast to the appropriate type for the corresponding data connection. For example, to access the properties and methods of a data connection for submitting a form in e-mail, you must cast the returned DataConnection object to the EmailSubmitConnection type.

This member can be accessed without restrictions.

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

Applies to