IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) Método

Definición

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

Parámetros

lLineageID
Int32
eUsageType
DTSUsageType

Devoluciones

El índice del recién creado IDTSInputColumn100, o -1 si eUsageType es UT_IGNORED y la columna se elimina de la colección de columnas de entrada.

Atributos

Ejemplos

El siguiente ejemplo de código muestra la implementación sobrescriturada de un componente que SetUsageType utiliza el SetUsageType de la entrada virtual para añadir y eliminar columnas de la colección de entrada. En este ejemplo, el componente no permite que las columnas sean escribibles, por lo que cuando eUsageType es UT_READWRITE ocurre una excepción.

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;  
}  
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  

Comentarios

Los desarrolladores de componentes personalizados llaman a este método, normalmente en su implementación sobrescrita del método de clase SetUsageType base, para añadir o eliminar columnas de la colección de columnas de entrada del componente. Si eUsageType es UT_IGNORED y la columna se ha añadido previamente a la colección de columnas de entrada del componente, se elimina el índice de columna. Si eUsageType es UT_READONLY o UT_READWRITE, la columna se añade a la colección.

Este método no debe ser llamado por desarrolladores que están creando programáticamente una tarea de flujo de datos y seleccionando columnas para los componentes de la tarea. En su lugar, debe llamarse al SetUsageType método de la instancia en tiempo de diseño del componente. Llamar a este método evita directamente la capacidad del componente para restringir columnas por tipo de dato o tipo de uso.

Se aplica a