Share via


DtsEventHandlers.Item 속성

Gets a DtsEventHandler object from the collection.

네임스페이스:  Microsoft.SqlServer.Dts.Runtime
어셈블리:  Microsoft.SqlServer.ManagedDTS(Microsoft.SqlServer.ManagedDTS.dll)

구문

‘선언
Public ReadOnly Default Property Item ( _
    index As Object _
) As DtsEventHandler 
    Get
‘사용 방법
Dim instance As DtsEventHandlers 
Dim index As Object 
Dim value As DtsEventHandler 

value = instance(index)
public DtsEventHandler this[
    Object index
] { get; }
public:
property DtsEventHandler^ default[Object^ index] {
    DtsEventHandler^ get (Object^ index);
}
member Item : DtsEventHandler
Jscript는 인덱싱된 속성의 사용을 지원하지만 새로운 인덱싱된 속성 선언은 지원하지 않습니다.

매개 변수

속성 값

유형: Microsoft.SqlServer.Dts.Runtime.DtsEventHandler
A DtsEventHandler object from the collection.

주의

If the call to the Contains method returns true, you can access the specified element in the collection by using the syntax DtsEventHandlers[index]. If the Contains method returns false, this property throws an exception. In C#, this property is the indexer for the DtsEventHandlers class.

The following code example retrieves the DtsEventHandlers collection, then uses Contains to see if the item syntax [x] can be used on the collection.

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

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package pkg = new Package();

            // Set up a DtsEventHandler for the OnError event of the package.
            DtsEventHandler dtsEHOE = (DtsEventHandler)pkg.EventHandlers.Add("OnError");
            DtsEventHandler dtsEHW = (DtsEventHandler)pkg.EventHandlers.Add("OnWarning");

            // Create the DtsEventHandlers collection.
            DtsEventHandlers dtsEHColls = pkg.EventHandlers;

            // Use the Contains method to see if the item[x] syntax can be used.
            Boolean dtsContains = dtsEHColls.Contains(0);
            Console.WriteLine("Item syntax can be used?  {0}", dtsContains);

            //Using the Item method syntax of [x], obtain the first entry and a name.
            DtsEventHandler dtsEHFirstEntry = dtsEHColls[0];
            String nameOfFirstItem = dtsEHColls[0].Name;

            //Print the name of the log provider object located at position [0].
            Console.WriteLine("The ID of the first event handler is: {0}", dtsEHFirstEntry.ID);
            Console.WriteLine("The Name of the first event handler is: {0}", nameOfFirstItem);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim pkg As Package =  New Package() 
 
            ' Set up a DtsEventHandler for the OnError event of the package.
            Dim dtsEHOE As DtsEventHandler = CType(pkg.EventHandlers.Add("OnError"), DtsEventHandler)
            Dim dtsEHW As DtsEventHandler = CType(pkg.EventHandlers.Add("OnWarning"), DtsEventHandler)
 
            ' Create the DtsEventHandlers collection.
            Dim dtsEHColls As DtsEventHandlers =  pkg.EventHandlers 
 
            ' Use the Contains method to see if the item[x] syntax can be used.
            Dim dtsContains As Boolean =  dtsEHColls.Contains(0) 
            Console.WriteLine("Item syntax can be used?  {0}", dtsContains)
 
            'Using the Item method syntax of [x], obtain the first entry and a name.
            Dim dtsEHFirstEnTry As DtsEventHandler =  dtsEHColls(0) 
            Dim nameOfFirstItem As String =  dtsEHColls(0).Name 
 
            'Print the name of the log provider object located at position [0].
            Console.WriteLine("The ID of the first event handler is: {0}", dtsEHFirstEnTry.ID)
            Console.WriteLine("The Name of the first event handler is: {0}", nameOfFirstItem)
        End Sub
    End Class
End Namespace

Sample Output:

Item syntax can be used? True

The ID of the first event handler is: {4B9E438E-BA17-4A51-8235-3072AFF92F99}

The Name of the first event handler is: OnError

참고 항목

참조

DtsEventHandlers 클래스

Microsoft.SqlServer.Dts.Runtime 네임스페이스