次の方法で共有


IDTSVirtualInput100.SetUsageType メソッド

仮想入力列オブジェクトをマップし、使用法の種類を設定します。

名前空間:  Microsoft.SqlServer.Dts.Pipeline.Wrapper
アセンブリ:  Microsoft.SqlServer.DTSPipelineWrap (Microsoft.SqlServer.DTSPipelineWrap.dll)

構文

'宣言
Function SetUsageType ( _
    lLineageID As Integer, _
    eUsageType As DTSUsageType _
) As Integer
'使用
Dim instance As IDTSVirtualInput100 
Dim lLineageID As Integer 
Dim eUsageType As DTSUsageType 
Dim returnValue As Integer 

returnValue = instance.SetUsageType(lLineageID, _
    eUsageType)
int SetUsageType(
    int lLineageID,
    DTSUsageType eUsageType
)
int SetUsageType(
    [InAttribute] int lLineageID, 
    [InAttribute] DTSUsageType eUsageType
)
abstract SetUsageType : 
        lLineageID:int * 
        eUsageType:DTSUsageType -> int
function SetUsageType(
    lLineageID : int, 
    eUsageType : DTSUsageType
) : int

パラメーター

戻り値

型: System.Int32
新しく作成された IDTSInputColumn100 のインデックスです。eUsageType が UT_IGNORED で、列が入力列コレクションから削除される場合は -1 です。

説明

カスタム コンポーネントの開発者は、通常、基本クラス SetUsageType メソッドのオーバーライドされた実装でこのメソッドを呼び出し、コンポーネントの入力列コレクションに対して列を追加または削除します。 eUsageType が UT_IGNORED であり、列が以前にコンポーネントの入力列コレクションに追加されている場合は、列のインデックスが削除されます。 eUsageType が UT_READONLY または UT_READWRITE である場合は、列がコレクションに追加されます。

プログラムでデータ フロー タスクを作成し、そのタスクでコンポーネントに対応する列を選択する場合、このメソッドを呼び出さないでください。 代わりに、コンポーネントのデザイン時インスタンスの SetUsageType メソッドを呼び出してください。 このメソッドを直接呼び出すと、データ型または使用法の種類によって列を制限するコンポーネントの機能がバイパスされます。

使用例

次のコード例は、仮想入力の 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

関連項目

参照

IDTSVirtualInput100 インターフェイス

Microsoft.SqlServer.Dts.Pipeline.Wrapper 名前空間