IDTSVirtualInput90.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)

Syntax

'Declaration
<DispIdAttribute(104)> _
Function SetUsageType ( _
    <InAttribute> lLineageID As Integer, _
    <InAttribute> eUsageType As DTSUsageType _
) As Integer
[DispIdAttribute(104)] 
int SetUsageType (
    [InAttribute] int lLineageID,
    [InAttribute] DTSUsageType eUsageType
)
[DispIdAttribute(104)] 
int SetUsageType (
    [InAttribute] int lLineageID, 
    [InAttribute] DTSUsageType eUsageType
)
/** @attribute DispIdAttribute(104) */ 
int SetUsageType (
    /** @attribute InAttribute() */ int lLineageID, 
    /** @attribute InAttribute() */ DTSUsageType eUsageType
)
DispIdAttribute(104) 
function SetUsageType (
    lLineageID : int, 
    eUsageType : DTSUsageType
) : int

Parameters

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

Return Value

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

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.

Example

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 IDTSInputColumn90 SetUsageType(int inputID, IDTSVirtualInput90 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.
    IDTSInput90 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 IDTSVirtualInput90, ByVal lineageID As Integer, ByVal usageType As DTSUsageType) As IDTSInputColumn90 
 If usageType = DTSUsageType.UT_READWRITE Then 
   Throw New Exception("Read write columns prohibited.") 
 End If 
 Dim input As IDTSInput90 = 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

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

IDTSVirtualInput90 Interface
IDTSVirtualInput90 Members
Microsoft.SqlServer.Dts.Pipeline.Wrapper Namespace