IDTSRuntimeConnection100.ConnectionManager 屬性

定義

public:
 property Microsoft::SqlServer::Dts::Runtime::Wrapper::Sql2014::IDTSConnectionManager100 ^ ConnectionManager { Microsoft::SqlServer::Dts::Runtime::Wrapper::Sql2014::IDTSConnectionManager100 ^ get(); void set(Microsoft::SqlServer::Dts::Runtime::Wrapper::Sql2014::IDTSConnectionManager100 ^ value); };
[System.Runtime.InteropServices.DispId(102)]
public Microsoft.SqlServer.Dts.Runtime.Wrapper.Sql2014.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.Sql2014.IDTSConnectionManager100 with get, set
Public Property ConnectionManager As IDTSConnectionManager100

屬性值

IDTSConnectionManager100

元件的 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 封裝的集合不會公開至元件。

適用於