Connections.Item[Object] 속성

정의

ConnectionManager 컬렉션에서 Connections 개체를 가져옵니다.

public:
 property Microsoft::SqlServer::Dts::Runtime::ConnectionManager ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::ConnectionManager ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.ConnectionManager this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.ConnectionManager
Default Public ReadOnly Property Item(index As Object) As ConnectionManager

매개 변수

index
Object

반환할 ConnectionManager 개체의 이름, ID 또는 인덱스입니다.

속성 값

컬렉션의 ConnectionManager 개체입니다.

예제

다음 코드 샘플은 두 가지 메서드를 사용하여 컬렉션에서 항목을 검색합니다. 첫 번째 메서드는 구문을 사용하여 conns[0] 컬렉션의 첫 번째 위치에 있는 전체 개체를 검색하고 변수에 myConnMgr 넣습니다. 이제 평소와 같이 모든 속성을 검색할 myConnMgr 수 있습니다. 두 번째 메서드는 구문을 사용하여 conns[0].<property> 컬렉션의 첫 번째 개체에서 특정 속성을 검색합니다.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace Connections_Item  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            // The package is one of the SSIS Samples.  
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";  

            // Create an application and load the sample.  
            Application app = new Application();  
            Package pkg = app.LoadPackage(mySample, null);  
            Connections conns = pkg.Connections;  

            //Using the Item method syntax of [x], obtain the  
            // entire first entry, and then just the name.  
            ConnectionManager myConnMgr = conns[0];  
            String nameOfFirstItem = conns[0].Name;  

            //Print the name of the connection manager located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", myConnMgr.ID);  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace Connections_Item  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            ' The package is one of the SSIS Samples.  
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"   

            ' Create an application and load the sample.  
            Dim app As Application =  New Application()   
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing)   
            Dim conns As Connections =  pkg.Connections   

            'Using the Item method syntax of [x], obtain the  
            ' entire first entry, and then just the name.  
            Dim myConnMgr As ConnectionManager =  conns(0)   
            Dim nameOfFirstItem As String =  conns(0).Name   

            'Print the name of the connection manager located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", myConnMgr.ID)  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem)  
        End Sub  
    End Class  
End Namespace  

샘플 출력:

The ID of the first connection info is: {B52C0D78-5402-4544-BFEC-2BE203900C91}

The Name of the first connection info is: Create_Execute_Process_Dest.sql

설명

메서드 호출이 Contains 반환 true되는 경우 구문을 Connections[index]사용하여 컬렉션에서 지정된 요소에 액세스할 수 있습니다. 메서드가 Contains 반환 false되는 경우 이 속성은 예외를 throw합니다. C#에서 이 속성은 Connections 클래스의 인덱서입니다.

적용 대상