Package.Connections Property


Gets the collection of connection managers for the package.

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

public Connections Connections { get; }

Property Value

Type: Microsoft.SqlServer.Dts.Runtime.Connections

The collection of connection managers for the package.

Connection managers provide tasks with a generic interface to the underlying data store, allowing for simpler task implementation. Use the AcquireConnection method of the ConnectionManager object to retrieve the necessary connection information from any of the connection manager objects in the collection.

The connection manager can be referenced by GUID or by name, and you can store the name of the connection manager in a configuration file. To reference the connection by name, use \Package.Connections[myConnection].ConnectionString, instead of using \Package.Connections[{9930DA64-A413-4286-9C66-74EDADB4F393}].ConnectionString.

For more information about connections and connection managers, see Integration Services (SSIS) Connections.

The following example loads the UsingExecuteProcess package sample, and then retrieves the connections that are used by the package and displays some properties about the connections.

static void Main(string[] args)
            // The variable pkg points to the location
            // of the ExecuteProcess package sample 
            // that is installed with the samples.
            string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            Application app = new Application();
            Package p = app.LoadPackage(pkg, null);
            Connections conns = p.Connections;
            foreach (ConnectionManager cm in conns)
                Console.WriteLine("Name = " + cm.CreationName + ", HostType = " + cm.HostType);

Sample Output:

Name = FILE, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager

Return to top