다음을 통해 공유


Executables.Item 속성

Gets an Executable object from the collection.

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

구문

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

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

매개 변수

속성 값

유형: Microsoft.SqlServer.Dts.Runtime.Executable
An Executable 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 Executables[index]. If the Contains returns false, this property throws an exception. In C#, this property is the indexer for the Executables class.

The following example is a modification of the sample found in Remove. It removes the executable using the item syntax.

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

namespace Executables_API
{
        class Program
        {
                static void Main(string[] args)
                {
                    Executable exec = pkg.Executables.Add("STOCK:BulkInsertTask");
                    TaskHost myTask = exec as TaskHost;
                    BulkInsertTask myBI = myTask.InnerObject as BulkInsertTask;
                    myBI.DebugMode = false;
                    myBI.CheckConstraints = false;
                    myBI.KeepIdentity = true;

                    // Obtain the collection.
                    Executables pgkExecs = pkg.Executables;
                    // Show the number of executables in the collection.
                    Console.WriteLine("The first package contains {0} executables", pgkExecs.Count);

                    // It is a requirement to Remove the task from the
                    // existing package before adding it to the new package.
                    // Remove the exectuable using the Executables[x] item syntax. 
                    DtsContainer c = (DtsContainer)pkg.Executables[0];
                    pkg.Executables.Remove(c);

                    // Show the number of executables in the collection afterwards.
                    Console.WriteLine("The first package now contains {0} executables", pgkExecs.Count);

                    Package pkg2 = new Package();
                    Executables p2Execs = pkg2.Executables;
                    // Show the number of executables in the second collection.
                    Console.WriteLine("The second package initially contains {0} executables", p2Execs.Count);
                    // Join the task from pkg to pkg2.
                    pkg2.Executables.Join(myTask);
                    // Show the number of executables in the second collection after Join.
                    Console.WriteLine("The second package now contains {0} executables", p2Execs.Count);

        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
 
Namespace Executables_API
        Class Program
                Shared  Sub Main(ByVal args() As String)
                    Dim exec As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask") 
                    Dim myTask As TaskHost =  exec as TaskHost 
                    Dim myBI As BulkInsertTask =  myTask.InnerObject as BulkInsertTask 
                    myBI.DebugMode = False
                    myBI.CheckConstraints = False
                    myBI.KeepIdentity = True
 
                    ' Obtain the collection.
                    Dim pgkExecs As Executables =  pkg.Executables 
                    ' Show the number of executables in the collection.
                    Console.WriteLine("The first package contains {0} executables", pgkExecs.Count)
 
                    ' It is a requirement to Remove the task from the
                    ' existing package before adding it to the new package.
                    ' Remove the exectuable using the Executables[x] item syntax. 
                    Dim c As DtsContainer = CType(pkg.Executables(0), DtsContainer)
                    pkg.Executables.Remove(c)
 
                    ' Show the number of executables in the collection afterwards.
                    Console.WriteLine("The first package now contains {0} executables", pgkExecs.Count)
 
                    Dim pkg2 As Package =  New Package() 
                    Dim p2Execs As Executables =  pkg2.Executables 
                    ' Show the number of executables in the second collection.
                    Console.WriteLine("The second package initially contains {0} executables", p2Execs.Count)
                    ' Join the task from pkg to pkg2.
                    pkg2.Executables.Join(myTask)
                    ' Show the number of executables in the second collection after Join.
                    Console.WriteLine("The second package now contains {0} executables", p2Execs.Count)
 
                End Sub
        End Class
End Namespace

Sample Output:

The first package contains 1 executables

The first package now contains 0 executables

The second package initially contains 0 executables

The second package now contains 1 executables

참고 항목

참조

Executables 클래스

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