Package.Connections Properti

Definisi

Mendapatkan kumpulan manajer koneksi untuk paket.

public:
 property Microsoft::SqlServer::Dts::Runtime::Connections ^ Connections { Microsoft::SqlServer::Dts::Runtime::Connections ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.Connections Connections { get; }
member this.Connections : Microsoft.SqlServer.Dts.Runtime.Connections
Public ReadOnly Property Connections As Connections

Nilai Properti

Connections

Pengumpulan manajer koneksi untuk paket.

Contoh

Contoh berikut memuat sampel paket UsingExecuteProcess , lalu mengambil koneksi yang digunakan oleh paket dan menampilkan beberapa properti tentang koneksi.

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  

Contoh Output:

Name = FILE, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager

Name = OLEDB, HostType = ConnectionManager

Keterangan

Pengelola koneksi menyediakan tugas dengan antarmuka generik ke penyimpanan data yang mendasar, memungkinkan implementasi tugas yang lebih sederhana. AcquireConnection Gunakan metode ConnectionManager objek untuk mengambil informasi koneksi yang diperlukan dari salah satu objek pengelola koneksi dalam koleksi.

Manajer koneksi dapat dirujuk oleh GUID atau berdasarkan nama, dan Anda dapat menyimpan nama manajer koneksi dalam file konfigurasi. Untuk mereferensikan koneksi menurut nama, gunakan \Package.Connections[myConnection].ConnectionString, alih-alih menggunakan \Package.Connections[{9930DA64-A413-4286-9C66-74EDADB4F393}].ConnectionString.

Untuk informasi selengkapnya tentang koneksi dan manajer koneksi, lihat Koneksi Integration Services (SSIS).

Berlaku untuk