Skip to content

Latest commit

 

History

History
121 lines (96 loc) · 5.62 KB

connecting-data-flow-components-programmatically.md

File metadata and controls

121 lines (96 loc) · 5.62 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords dev_langs
Connecting Data Flow Components Programmatically
Connecting Data Flow Components Programmatically
chugugrace
chugu
03/06/2017
sql
integration-services
reference
data flow task [Integration Services], components
paths [Integration Services], components
components [Integration Services], data flow
data flow [Integration Services], components
VB
CSharp

Connecting Data Flow Components Programmatically

[!INCLUDEsqlserver-ssis]

After you have added components to the data flow task, you connect them to create an execution tree that represents the flow of data from sources through transformations to destinations. You use xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSPath100 objects to connect the components in the data flow.

Creating a Path

Call the New method of the xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.MainPipeClass.PathCollection%2A property of the xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.MainPipe interface to create a new path and add it to the collection of paths in the data flow task. This method returns a new, disconnected xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSPath100 object, which you then use to connect two components.

Call the xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSPath100.AttachPathAndPropagateNotifications%2A method to connect the path and to notify the components participating in the path that they have been connected. This method accepts an xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutput100 of the upstream component and an xref:Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSInput100 of the downstream component as parameters. By default, the call to the component's xref:Microsoft.SqlServer.Dts.Pipeline.PipelineComponent.ProvideComponentProperties%2A method creates a single input for components that have inputs, and a single output for components that have outputs. The following example uses this default output of the source and input of the destination.

Next Step

After you establish a path between two components, the next step is to map input columns in the downstream component, which is discussed in the next topic, Selecting Input Columns Programmatically.

Sample

The following code sample shows how to establish a path between two components.

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("STOCK:PipelineTask");  
      TaskHost thMainPipe = e as TaskHost;  
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;  
  
      // Create the source component.    
      IDTSComponentMetaData100 source =  
        dataFlowTask.ComponentMetaDataCollection.New();  
      source.ComponentClassID = "DTSAdapter.OleDbSource";  
      CManagedComponentWrapper srcDesignTime = source.Instantiate();  
      srcDesignTime.ProvideComponentProperties();  
  
      // Create the destination component.  
      IDTSComponentMetaData100 destination =  
        dataFlowTask.ComponentMetaDataCollection.New();  
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";  
      CManagedComponentWrapper destDesignTime = destination.Instantiate();  
      destDesignTime.ProvideComponentProperties();  
  
      // Create the path.  
      IDTSPath100 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("STOCK:PipelineTask")  
    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 IDTSComponentMetaData100 = _  
      dataFlowTask.ComponentMetaDataCollection.New()  
    source.ComponentClassID = "DTSAdapter.OleDbSource"  
    Dim srcDesignTime As CManagedComponentWrapper = source.Instantiate()  
    srcDesignTime.ProvideComponentProperties()  
  
    ' Create the destination component.  
    Dim destination As IDTSComponentMetaData100 = _  
      dataFlowTask.ComponentMetaDataCollection.New()  
    destination.ComponentClassID = "DTSAdapter.OleDbDestination"  
    Dim destDesignTime As CManagedComponentWrapper = destination.Instantiate()  
    destDesignTime.ProvideComponentProperties()  
  
    ' Create the path.  
    Dim path As IDTSPath100 = dataFlowTask.PathCollection.New()  
    path.AttachPathAndPropagateNotifications(source.OutputCollection(0), _  
      destination.InputCollection(0))  
  
  End Sub  
  
End Module  

See Also

Selecting Input Columns Programmatically