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

マッピングされているIDTSVirtualInputColumn100LineageID

eUsageType
DTSUsageType

DTSUsageType列挙の中の値で、入力列がコンポーネントでどのように使われているかを示します。

返品

新たに作成された IDTSInputColumn100のインデックス、または eUsageTypeUT_IGNORED され、その列が入力カラムコレクションから削除された場合は -1 です。

属性

以下のコード例は、仮想入力のSetUsageTypeを使って入力コレクションから列を追加・削除するコンポーネントの上書きされたSetUsageType実装を示しています。 この例では、コンポーネントが列を書き込むことを許可していないため、 eUsageTypeUT_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 メソッドを呼び出しるべきです。 このメソッドを呼び出すことで、コンポーネントがデータ型や使用型で列を制限する機能を直接回避できます。

適用対象