Click here to Skip to main content
12,898,500 members (68,471 online)
Click here to Skip to main content
Articles » Database » Database » SQL Server » Downloads

Stats

282.8K views
2.3K downloads
82 bookmarked
Posted 25 May 2006

Execute SQL Server 2005 Integration Services package from C#

, 25 May 2006
Learn how to load and execute a SQL Server 2005 Integration Services package from C# code
ExamplePackage.dtsConfig
ExamplePackage.dtsx
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace ExecuteSSIS
{
  class Program
  {
    static void Main(string[] args)
      {
        Application app = new Application();
        //
        // Load package from file system
        //
        Package package = app.LoadPackage("c:\\ExamplePackage.dtsx", null);
        package.ImportConfigurationFile("c:\\ExamplePackage.dtsConfig");
        Variables vars = package.Variables;
        vars["MyVariable"].Value = "value from c#";

        DTSExecResult result = package.Execute();

        Console.WriteLine("Package Execution results: {0}",result.ToString());

        //
        // Load package from Sql Server
        //
        Package package2 = app.LoadFromSqlServer(
            "ExamplePackage","server_name", "sa", "your_password", null);

        package2.ImportConfigurationFile("c:\\ExamplePackage.dtsConfig");
        Variables vars2 = package2.Variables;
        vars2["MyVariable"].Value = "value from c# again";

        DTSExecResult result2 = package2.Execute();

        Console.WriteLine("Package Execution results: {0}", 
             result2.ToString());


     }

  }

 }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Jeff Modzel
Web Developer
United States United States
Technical Architect
Sungard HE

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 25 May 2006
Article Copyright 2006 by Jeff Modzel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid