IDTSRuntimeConnection100.ConnectionManager 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置由运行时连接对象引用的 IDTSConnectionManager100 对象。
public:
 property Microsoft::SqlServer::Dts::Runtime::Wrapper::IDTSConnectionManager100 ^ ConnectionManager { Microsoft::SqlServer::Dts::Runtime::Wrapper::IDTSConnectionManager100 ^ get(); void set(Microsoft::SqlServer::Dts::Runtime::Wrapper::IDTSConnectionManager100 ^ value); };[System.Runtime.InteropServices.DispId(102)]
public Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager100 ConnectionManager { [System.Runtime.InteropServices.DispId(102)] get; [System.Runtime.InteropServices.DispId(102)] set; }[<System.Runtime.InteropServices.DispId(102)>]
[<get: System.Runtime.InteropServices.DispId(102)>]
[<set: System.Runtime.InteropServices.DispId(102)>]
member this.ConnectionManager : Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager100 with get, setPublic Property ConnectionManager As IDTSConnectionManager100属性值
- 属性
示例
下面的代码示例演示如何 ConnectionManager 在以编程方式加载包时设置属性。
// 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]);  
                else  
                    Console.WriteLine("The ConnectionManager " + rc.ConnectionManagerID + " was not found in the Package's Connections collection.");  
            }  
        }  
    }  
}  
' TODO: Replace the path to the package with a valid path.  
Dim package As String = "c:\Package.dtsx"   
' Create the application and load the package.  
Dim a As Application = New Application   
Dim p As Package = a.LoadPackage(package, Nothing)   
' Walk the Executables collection looking for data flow tasks.  
For Each e As Executable In p.Executables   
 Dim mp As MainPipe = CType(CType(e, TaskHost).InnerObject, MainPipe)   
 If Not (e Is Nothing) Then   
   ' Walk the components.  
   For Each md As IDTSComponentMetaData100 In mp.ComponentMetaDataCollection   
     ' Walk the RuntimeConnectionCollection.  
     For Each rc As IDTSRuntimeConnection100 In md.RuntimeConnectionCollection   
       ' Check to see whether the package's connections collection    
       '  contains the Connectionmanager stored in the RuntimeConnection.  
       If p.Connections.Contains(rc.ConnectionManagerID) Then   
         rc.ConnectionManager = DtsConvert.ToConnectionManager100(p.Connections(rc.ConnectionManagerID))   
       Else   
         Console.WriteLine("The ConnectionManager " + rc.ConnectionManagerID + " was not found in the Package's Connections collection.")   
       End If   
     Next   
   Next   
 End If   
Next  
注解
该 ConnectionManager 属性包含或设置对包中包含的对象的实际实例的 IDTSConnectionManager100 引用。 在运行时,SSIS 运行时引擎使用 ConnectionManagerID 属性在包中定位连接并分配引用,自动设置此引用。
在设计时,SSIS 设计器在加载和初始化组件时执行此分配。 但是,当以编程方式加载和编辑组件时,必须使用设计器外部的对象模型显式设置该属性。 组件不能使用 ConnectionManagerID 属性显式引用连接,因为 Connections 包的集合不会向组件公开。