IDTSRuntimeConnection100.ConnectionManager Property

Gets or sets the IDTSConnectionManager100 object referenced by the run-time connection object.

Namespace:  Microsoft.SqlServer.Dts.Pipeline.Wrapper
Assembly:  Microsoft.SqlServer.DTSPipelineWrap (in Microsoft.SqlServer.DTSPipelineWrap.dll)

IDTSConnectionManager100 ConnectionManager { get; set; }

The ConnectionManager property contains, or sets, a reference to the actual instance of the IDTSConnectionManager100 object contained in the package. At runtime, this reference is set automatically by the SSIS runtime engine using the ConnectionManagerID property to locate the connection in the package and assign a reference.

At design time SSIS Designer does this assignment when loading and initializing a component. However, when programmatically loading and editing a component, using the object model outside of the designer, the property must be set explicitly. Components do not have the ability to reference the connection explicitly using the ConnectionManagerID property because the Connections collection of the package is not exposed to components.

The following code example shows how the ConnectionManager property is set when programmatically loading a package.

// TODO: Replace the path to the package with a valid path.
string package = @"c:\Package.dtsx";

// Create the application and load the package.
Application a = new Application();
Package p = a.LoadPackage( package , null );

// Walk the Executables collection looking for data flow tasks.
foreach (Executable e in p.Executables)
    MainPipe mp = ((TaskHost)e).InnerObject as MainPipe;
    if( e != null )
        // Walk the components.
        foreach( IDTSComponentMetaData100 md in mp.ComponentMetaDataCollection )
            // Walk the RuntimeConnectionCollection.
            foreach( IDTSRuntimeConnection100 rc in md.RuntimeConnectionCollection )
                // Check to see if the package's connections collection contains the 
                // Connectionmanager stored in the RuntimeConnection.
                if (p.Connections.Contains(rc.ConnectionManagerID))
                    rc.ConnectionManager = DtsConvert.ToConnectionManager100(p.Connections[rc.ConnectionManagerID]);
                    Console.WriteLine("The ConnectionManager " + rc.ConnectionManagerID + " was not found in the Package's Connections collection.");

Community Additions