IDTSVirtualInput100.SetUsageType(Int32, DTSUsageType) 方法

定義

public:
 int SetUsageType(int lLineageID, Microsoft::SqlServer::Dts::Pipeline::Wrapper::Sql2012::DTSUsageType eUsageType);
[System.Runtime.InteropServices.DispId(104)]
public int SetUsageType(int lLineageID, Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2012.DTSUsageType eUsageType);
[<System.Runtime.InteropServices.DispId(104)>]
abstract member SetUsageType : int * Microsoft.SqlServer.Dts.Pipeline.Wrapper.Sql2012.DTSUsageType -> int
Public Function SetUsageType (lLineageID As Integer, eUsageType As DTSUsageType) As Integer

參數

lLineageID
Int32
eUsageType
DTSUsageType

傳回

新建立 IDTSInputColumn100的索引 ,若為 UT_IGNORED,則 -1 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 方法實作中,來新增或移除元件輸入欄位集合中的欄位。 若 eUsageType UT_IGNORED,且該欄位先前已被加入元件的輸入欄位集合,則欄位索引將被移除。 若 eUsageType UT_READONLY 或 UT_READWRITE,則該欄位會加入集合。

開發者在程式化建立資料流程任務並選擇任務欄位時,不應呼叫此方法。 相反地, SetUsageType 應該呼叫元件設計時實例的方法。 呼叫此方法可直接繞過元件依資料型別或使用型別限制欄位的能力。

適用於