語言

IDTSComponentMetaDataCollection100.New 方法

定義

建立一個新 IDTSComponentMetaData100 物件並加入 IDTSComponentMetaDataCollection100 集合。

public:
 Microsoft::SqlServer::Dts::Pipeline::Wrapper::IDTSComponentMetaData100 ^ New();
[System.Runtime.InteropServices.DispId(14)]
public Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100 New();
[<System.Runtime.InteropServices.DispId(14)>]
abstract member New : unit -> Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100
Public Function New () As IDTSComponentMetaData100

傳回

新創造 IDTSComponentMetaData100 的物品。

屬性

範例

以下程式碼範例透過呼叫 New 類別的方法 MainPipe ,將 OLE DB 原始碼元件加入資料流程任務。

using System;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;  

namespace Microsoft.Samples.SqlServer.Dts  
{  
    class CreateComponent  
    {  
         [STAThread]  
        static void Main(string[] args)  
        {  
            // Create the package.  
            Package p = new Package();  

            // Add the data flow task to the package.  
            MainPipe dataFlowTask = ((TaskHost)p.Executables.Add("DTS.Pipeline.1")).InnerObject as MainPipe;  

            if (dataFlowTask != null)  
            {  
                // Add a component to the data flow task.  
                IDTSComponentMetaData100 metaData = dataFlowTask.ComponentMetaDataCollection.New();  

                // Set the class ID of the component.  
                metaData.ComponentClassID = "DTSAdapter.OLEDBSource.1";  

                // Create an instance of the component.  
                CManagedComponentWrapper wrapper = metaData.Instantiate();  

                // Initialize the component.  
                wrapper.ProvideComponentProperties();  
            }  
        }  
    }  
}  

備註

資料流元件可透過呼叫 New 的 ComponentMetaDataCollection方法加入MainPipe類別。

適用於