次の方法で共有


プログラムによるデータ フロー コンポーネントの接続

データ フロー タスクにコンポーネントを追加したら、コンポーネントを接続して、変換元から変換を経由して変換先に至るデータ フローを表す実行ツリーを作成します。データ フロー内のコンポーネントを接続するには、IDTSPath90 オブジェクトを使用します。

パスの作成

MainPipe インターフェイスの PathCollection プロパティの New メソッドを呼び出して、新しいパスを作成し、データ フロー タスク内のパスのコレクションに追加します。このメソッドは、新しく作成され、切断されている IDTSPath90 オブジェクトを返します。これを使用して 2 つのコンポーネントを接続します。

パスを接続し、パスに含まれているコンポーネントが接続されたことを通知するには、AttachPathAndPropagateNotifications メソッドを呼び出します。このメソッドは、上流コンポーネントの IDTSOutput90 および下流コンポーネントの IDTSInput90 をパラメータとして受け取ります。既定では、コンポーネントの ProvideComponentProperties メソッドを呼び出すと、入力を持つコンポーネントに 1 つの入力、および出力を持つコンポーネントに 1 つの出力が作成されます。次の例では、この既定の変換元の出力および変換先の入力を使用します。

次の手順

2 つのコンポーネント間のパスを確立したら、次に入力列を下流コンポーネントにマップします。この手順については、次の「プログラムによる入力列の選択」で説明します。

サンプル

次のコード例は、2 つのコンポーネント間でパスを確立する方法を示します。

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

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      Package package = new Package();
      Executable e = package.Executables.Add("DTS.Pipeline.1");
      TaskHost thMainPipe = e as TaskHost;
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

      // Create the source component.  
      IDTSComponentMetaData90 source =
        dataFlowTask.ComponentMetaDataCollection.New();
      source.ComponentClassID = "DTSAdapter.OleDbSource";
      CManagedComponentWrapper srcDesignTime = source.Instantiate();
      srcDesignTime.ProvideComponentProperties();

      // Create the destination component.
      IDTSComponentMetaData90 destination =
        dataFlowTask.ComponentMetaDataCollection.New();
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";
      CManagedComponentWrapper destDesignTime = destination.Instantiate();
      destDesignTime.ProvideComponentProperties();

      // Create the path.
      IDTSPath90 path = dataFlowTask.PathCollection.New();
      path.AttachPathAndPropagateNotifications(source.OutputCollection[0],
        destination.InputCollection[0]);
    }
  }

}

Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Module Module1

  Sub Main()

    Dim package As Microsoft.SqlServer.Dts.Runtime.Package = _
      New Microsoft.SqlServer.Dts.Runtime.Package()
    Dim e As Executable = package.Executables.Add("DTS.Pipeline.1")
    Dim thMainPipe As Microsoft.SqlServer.Dts.Runtime.TaskHost = _
      CType(e, Microsoft.SqlServer.Dts.Runtime.TaskHost)
    Dim dataFlowTask As MainPipe = CType(thMainPipe.InnerObject, MainPipe)

    ' Create the source component.  
    Dim source As IDTSComponentMetaData90 = _
      dataFlowTask.ComponentMetaDataCollection.New()
    source.ComponentClassID = "DTSAdapter.OleDbSource"
    Dim srcDesignTime As CManagedComponentWrapper = source.Instantiate()
    srcDesignTime.ProvideComponentProperties()

    ' Create the destination component.
    Dim destination As IDTSComponentMetaData90 = _
      dataFlowTask.ComponentMetaDataCollection.New()
    destination.ComponentClassID = "DTSAdapter.OleDbDestination"
    Dim destDesignTime As CManagedComponentWrapper = destination.Instantiate()
    destDesignTime.ProvideComponentProperties()


    ' Create the path.
    Dim path As IDTSPath90 = dataFlowTask.PathCollection.New()
    path.AttachPathAndPropagateNotifications(source.OutputCollection(0), _
      destination.InputCollection(0))

  End Sub

End Module

変更履歴

リリース 履歴

2006 年 7 月 17 日

変更内容 :
  • コード例をより長いサンプルと取り替えました。

参照

概念

プログラムによる入力列の選択

ヘルプおよび情報

SQL Server 2005 の参考資料の入手