Export (0) Print
Expand All

IDTSVirtualInput100.SetUsageType Method

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

Namespace:  Microsoft.SqlServer.Dts.Pipeline.Wrapper
Assembly:  Microsoft.SqlServer.DTSPipelineWrap (in Microsoft.SqlServer.DTSPipelineWrap.dll)

[DispIdAttribute()]
int SetUsageType(
	int lLineageID,
	DTSUsageType eUsageType
)

Parameters

lLineageID
Type: Int32
The LineageID of the IDTSVirtualInputColumn100 that is being mapped.
eUsageType
Type: Microsoft.SqlServer.Dts.Pipeline.Wrapper.DTSUsageType
A value from the DTSUsageType enumeration that indicates how the input column is used by the component.

Return Value

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

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.

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;
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft