共用方式為


IDTSVirtualInput90.SetUsageType Method

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

命名空間: Microsoft.SqlServer.Dts.Pipeline.Wrapper
組件: Microsoft.SqlServer.DTSPipelineWrap (in microsoft.sqlserver.dtspipelinewrap.dll)

語法

'宣告
<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

參數

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

傳回值

The index of the newly created IDTSInputColumn90, 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 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

執行緒安全性

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.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

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