Share via


Executables.Join(Executable) 메서드

정의

Executables 컬렉션에 기존 컨테이너 또는 태스크 개체를 추가합니다.

public:
 void Join(Microsoft::SqlServer::Dts::Runtime::Executable ^ executable);
public void Join (Microsoft.SqlServer.Dts.Runtime.Executable executable);
member this.Join : Microsoft.SqlServer.Dts.Runtime.Executable -> unit
Public Sub Join (executable As Executable)

매개 변수

executable
Executable

컨테이너 또는 태스크에 대한 기존 TaskHost의 이름입니다.

예제

다음 예제에서는 대량 삽입 작업을 만들고 일부 속성을 설정합니다. 그런 다음 대량 삽입 태스크가 첫 번째 패키지에서 제거되고 두 번째 패키지에 추가됩니다. 첫 번째 패키지의 일부인 동안 설정된 속성은 변경되지 않은 상태로 유지됩니다.

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)  
        {  
                      // Create the package and add the BulkInsertTask.  
                      Package pkg = new Package();  
                      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.  
                      pkg.Executables.Remove(0);  
                      // 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)  
                      ' Create the package and add the BulkInsertTask.  
                      Dim pkg As Package =  New Package()   
                      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.  
                      pkg.Executables.Remove(0)  
                      ' 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  

샘플 출력:

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

설명

컨테이너 또는 작업을 한 컨테이너(원본)에서 다른 컨테이너(대상)로 이동할 때 사용합니다 Join . 대상을 호출 Join 하기 전에 원본 컨테이너에서 개체를 Remove 제거해야 합니다.

적용 대상