API Sample – Create a package with a data flow task

This code creates a package with a single data flow task. It will be used as a base for the more complicated code samples.

static void Main(string[] args)
    Package package = new Package();

    // Add Data Flow Task
    Executable dataFlowTask = package.Executables.Add("STOCK:PipelineTask");

    // Set the name (otherwise it will be a random GUID value)
    TaskHost taskHost = dataFlowTask as TaskHost;
    taskHost.Name = "Data Flow Task";

    // We need a reference to the InnerObject to add items to the data flow
    MainPipe pipeline = taskHost.InnerObject as MainPipe;

Comments (6)

Cancel reply

  1. This is an index post for the series of posts with examples on how to create packages programmatically.

  2. 1. 构建一个包含数据流任务(Data Flow Task)的包 下面的代码可以生成一个包含数据流任务的包,这个包不执行任何实际的工作,但是可以作为构建一个更复杂的包的基础: static void Main(

  3. stevenhoward says:

    Hello Matt,

    The samples you give are very good, but I really wish we had either a list of prerequisites, or a link to actually setting up the project to get to the point where this is helpful to us. For example, if I create a project, and just replace the main with your code sample, I get errors when I try to compile telling me that the Type or Namespace ‘Package’ cannot be found.

    Could you help us get to the point where your samples work? Thank you for your work!

  4. ALi says:

    Hi Stevenhowards !

       1) You should add reference: Microsoft.SQLServer.DtsRuntimeWrap

        2) Then add using Microsoft.SqlServer.Dts.Runtime; in top of your code

    Goodluck !

  5. sree says:


    how prepare a ssis package to load the data from a flatfile

    just show me the code

  6. Renjith says:

    Hi can anyone tell me the hierarchy how we should create the package when we does programmatically and why to do in that order? Like Package –> ControlFlow –> DataFlow and so on.

Skip to main content