IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) 方法

定义

映射虚拟输入列对象并设置其使用类型。

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

参数

lLineageID
Int32

LineageID IDTSVirtualInputColumn100正在绘制的部分。

eUsageType
DTSUsageType

枚举中的一个值 DTSUsageType ,表示组件如何使用输入列。

返回

新创建IDTSInputColumn100的索引 或 -1 如果是UT_IGNORED,则eUsageType列从输入列集合中移除。

属性

示例

以下代码示例展示了组件覆盖的实现 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 方法实现中调用此方法,以添加或移除组件输入列集合中的列。 如果 eUsageTypeUT_IGNORED,且该列之前已被添加到组件的输入列集合中,则列索引被移除。 如果 eUsageTypeUT_READONLY,或 UT_READWRITE,则该列被添加到集合中。

开发者在程序化创建数据流任务并为任务中组件选择列时,不应调用此方法。 相反, SetUsageType 应调用组件设计时实例的方法。 调用此方法直接绕过组件按数据类型或使用类型限制列的能力。

适用于