Share via


Connections プロパティ

パッケージの接続マネージャーのコレクションを返します。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public ReadOnly Property Connections As Connections
    Get
'使用
Dim instance As Package
Dim value As Connections

value = instance.Connections
public Connections Connections { get; }
public:
property Connections^ Connections {
    Connections^ get ();
}
member Connections : Connections
function get Connections () : Connections

プロパティ値

型: Microsoft.SqlServer.Dts.Runtime. . :: . .Connections
Connections コレクションです。

説明

接続マネージャーは、タスクに基となるデータ ストアへの汎用インターフェイスを提供し、より簡単にタスクを実装できるようにします。ConnectionManager オブジェクトの AcquireConnection メソッドを使用し、コレクションの任意の接続マネージャー オブジェクトから必要な接続情報を取得します。

接続マネージャーは、GUID または名前で参照できます。接続マネージャーの名前は構成ファイルに格納できます。接続を名前で参照するには、\Package.Connections[{9930DA64-A413-4286-9C66-74EDADB4F393}].ConnectionString ではなく \Package.Connections[myConnection].ConnectionString を使用します。

接続と接続マネージャーの詳細については、「Integration Services の接続」を参照してください。

使用例

次の例では、UsingExecuteProcess パッケージ サンプルを読み込み、パッケージによって使用される接続を取得して、接続に関するいくつかのプロパティを表示します。

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);
        }
Shared  Sub Main(ByVal args() As String)
            ' The variable pkg points to the location
            ' of the ExecuteProcess package sample 
            ' that is installed with the samples.
            Dim pkg As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" 
 
            Dim app As Application =  New Application() 
            Dim p As Package =  app.LoadPackage(pkg,Nothing) 
            Dim conns As Connections =  p.Connections 
            Dim cm As ConnectionManager
            For Each cm In conns
                Console.WriteLine("Name = " + cm.CreationName + ", HostType = " + cm.HostType)
            Next
End Sub

サンプルの出力 :

Name = FILE, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager