IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) Método

Definición

public:
 int SetUsageType(int lLineageID, Microsoft::SqlServer::Dts::Pipeline::Wrapper::Sql2014::DTSUsageType eUsageType);
[System.Runtime.InteropServices.DispId(104)]
public int SetUsageType (int lLineageID, Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2014.DTSUsageType eUsageType);
[<System.Runtime.InteropServices.DispId(104)>]
abstract member SetUsageType : int * Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2014.DTSUsageType -> int
Public Function SetUsageType (lLineageID As Integer, eUsageType As DTSUsageType) As Integer

Parámetros

lLineageID
Int32
eUsageType
DTSUsageType

Devoluciones

Índice del objeto recién creado IDTSInputColumn100o -1 si eUsageType está UT_IGNORED y la columna se quita de la colección de columnas de entrada.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra la implementación invalidada de un componente de SetUsageType que usa setUsageType de la entrada virtual para agregar y quitar columnas de la colección de entrada. En este ejemplo, el componente no permite que las columnas se puedan escribir, por lo que cuando eUsageType se UT_READWRITE se produce una excepción.

Public Overrides Function SetUsageType(ByVal inputID As Integer, ByVal virtualInput As IDTSVirtualInput100, ByVal lineageID As Integer, ByVal usageType As DTSUsageType) As IDTSInputColumn100   
 If usageType = DTSUsageType.UT_READWRITE Then   
   Throw New Exception("Read write columns prohibited.")   
 End If   
 Dim input As IDTSInput100 = ComponentMetaData.InputCollection.GetObjectByID(inputID)   
 Dim index As Integer = virtualInput.SetUsageType(lineageID, usageType)   
 If Not (index = -1) Then   
   Return input.InputColumnCollection(index - 1)   
 End If   
 Return Nothing   
End Function  
public override IDTSInputColumn100 SetUsageType(int inputID, IDTSVirtualInput100 virtualInput, int lineageID, DTSUsageType usageType)  
{  
    // Prevent use of read/write columns.  
    if (usageType == DTSUsageType.UT_READWRITE)  
        throw new Exception("Read write columns prohibited.");  

    // Get the input specified by inputID.  
    IDTSInput100 input = ComponentMetaData.InputCollection.GetObjectByID(inputID);  

    int index = virtualInput.SetUsageType(lineageID, usageType);  

    // If the index is not -1, return the column.  
    // NOTE: The index that is returned is 1-based, but the input column collection is 0-based.  
    if ( index != -1 )  
        return input.InputColumnCollection[index-1];  

    // The column was removed, so return null.  
    return null;  
}  

Comentarios

Los desarrolladores de componentes personalizados llaman a este método, normalmente en su implementación invalidada del método de clase SetUsageType base, para agregar o quitar columnas de la colección de columnas de entrada del componente. Si eUsageType es UT_IGNORED y la columna se ha agregado previamente a la colección de columnas de entrada del componente, se quita el índice de columna. Si eUsageType es UT_READONLY o UT_READWRITE, la columna se agrega a la colección.

Los desarrolladores que crean mediante programación una tarea de flujo de datos y seleccionan columnas para los componentes de la tarea no deben llamar a este método. En su lugar, se debe llamar al SetUsageType método de la instancia en tiempo de diseño del componente. Al llamar a este método, se omite directamente la capacidad del componente de restringir las columnas por tipo de datos o tipo de uso.

Se aplica a