Compartir a través de


Executables.Remove Method

Removes an Executable object from the collection.

Espacio de nombres: Microsoft.SqlServer.Dts.Runtime
Ensamblado: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Sintaxis

'Declaración
Public Sub Remove ( _
    index As Object _
)
public void Remove (
    Object index
)
public:
void Remove (
    Object^ index
)
public void Remove (
    Object index
)
public function Remove (
    index : Object
)

Parámetros

  • index
    The index of the Executable object to remove.

Ejemplo

The following example creates a Bulk Insert Task and sets some properties. The Bulk Insert Task is then removed from the first package, and added to the second package. The properties set while it was part of the first package remain unchanged.

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

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

Seguridad para subprocesos

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

Executables Class
Executables Members
Microsoft.SqlServer.Dts.Runtime Namespace