IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) Method

Definition

Maps a virtual input column object and sets its usage type.

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

Parameters

lLineageID
Int32

The LineageID of the IDTSVirtualInputColumn100 that is being mapped.

eUsageType
DTSUsageType

A value from the DTSUsageType enumeration that indicates how the input column is used by the component.

Returns

The index of the newly created IDTSInputColumn100, or -1 if eUsageType is UT_IGNORED and the column is removed from the input column collection.

Attributes

Examples

The following code example shows a component's overridden implementation of SetUsageType that uses the virtual input's SetUsageType to add and remove columns from the input collection. In this example, the component does not allow columns to be writeable so when eUsageType is UT_READWRITE an exception occurs.

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  

Remarks

Custom component developers call this method, usually in their overridden implementation of the base class SetUsageType method, to add or remove columns from the input column collection of the component. If eUsageType is UT_IGNORED, and the column has previously been added to the input column collection of the component, the column index is removed. If eUsageType is UT_READONLY, or UT_READWRITE, the column is added to the collection.

This method should not be called by developers who are programmatically creating a data flow task and selecting columns for the components in the task. Instead, the SetUsageType method of the design-time instance of the component should be called. Calling this method directly bypasses the component's ability to restrict columns by data type or usage type.

Applies to