ConnectionInfos.Contains Method

Returns a Boolean that indicates whether the ConnectionInfo items in the ConnectionInfos collection can be accessed by using the name, index, ID, or identity parameter as the index.

Namespace:  Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public bool Contains(
	Object index


Type: System.Object
The name, index, ID, or identity of the object in the collection to match.

Return Value

Type: System.Boolean
true indicates that you can retrieve the item using the syntax ConnectionInfos[index]; false indicates that indexing cannot be used to retrieve items from the ConnectionInfos collection.

The following example shows a search of the collection for the connection "DTS Connection Manager for Files". The name used in the search is the name returned in the Name property.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace ConnInfosTest
    class Program
        static void Main(string[] args)
            Application dtsApplication = new Application();
            ConnectionInfos connectionInfos = dtsApplication.ConnectionInfos;

            // Search for the File connection in the collection
            if (connectionInfos.Contains("DTS Connection Manager for Files"))
                Console.WriteLine("The collection contains the FILE connection");
                Console.WriteLine("The collection does not contain the FILE connection");

Sample Output:

The collection contains the FILE connection

Community Additions