IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) Метод

Определение

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

Параметры

lLineageID
Int32
eUsageType
DTSUsageType

Возвращаемое значение

Индекс новосозданного IDTSInputColumn100, или -1 если eUsageType равен UT_IGNORED, и столбец удаляется из коллекции входных столбцов.

Атрибуты

Примеры

Следующий пример кода показывает переопределённую реализацию компонента, SetUsageType которая использует SetUsageType виртуального входа для добавления и удаления столбцов из входной коллекции. В этом примере компонент не позволяет записывать столбцы, поэтому когда eUsageType UT_READWRITE возникает исключение.

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  

Комментарии

Разработчики пользовательских компонентов вызывают этот метод, обычно в своей переопределённой реализации базового класса SetUsageType , для добавления или удаления столбцов из входной коллекции компонента. Если eUsageType UT_IGNORED, и столбец ранее был добавлен в набор входных столбцов компонента, индекс столбца удаляется. Если eUsageType UT_READONLY или UT_READWRITE, столбец добавляется в коллекцию.

Этот метод не должен вызываться разработчиками, которые программно создают задачу потока данных и выбирают столбцы для компонентов задачи. Вместо этого следует вызвать метод экземпляра компонента SetUsageType во время проектирования. Вызов этого метода напрямую обходит возможность компонента ограничивать столбцы по типу данных или типу использования.

Применяется к