IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
int SetUsageType(int lLineageID, Microsoft::SqlServer::Dts::Pipeline::Wrapper::Sql2014::DTSUsageType eUsageType);
[System.Runtime.InteropServices.DispId(104)]
public int SetUsageType (int lLineageID, Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2014.DTSUsageType eUsageType);
[<System.Runtime.InteropServices.DispId(104)>]
abstract member SetUsageType : int * Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2014.DTSUsageType -> int
Public Function SetUsageType (lLineageID As Integer, eUsageType As DTSUsageType) As Integer
参数
- lLineageID
- Int32
- eUsageType
- DTSUsageType
返回
新创建的 IDTSInputColumn100的索引;如果 eUsageType
UT_IGNORED 并且从输入列集合中删除该列,则为 -1。
- 属性
示例
下面的代码示例演示组件的替代实现,该实现 SetUsageType 使用虚拟输入的 SetUsageType 在输入集合中添加和删除列。 在此示例中, 组件不允许列可写,因此当 eUsageType
为 时UT_READWRITE发生异常。
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
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;
}
注解
自定义组件开发人员通常在其基类 SetUsageType 方法的重写实现中调用此方法,以在组件的输入列集合中添加或删除列。 如果 eUsageType
UT_IGNORED,并且该列之前已添加到组件的输入列集合中,则删除列索引。 如果 eUsageType
为 UT_READONLY 或 UT_READWRITE,则会将该列添加到集合中。
以编程方式创建数据流任务并为任务中的组件选择列的开发人员不应调用此方法。 相反, SetUsageType 应调用 组件的设计时实例的 方法。 调用此方法会直接绕过组件按数据类型或用法类型限制列的功能。