"None can stop the rising sun, clouds can hide for a while........" -Ravi

Wednesday, May 26, 2010

Excute SSIS package from .NET application

Fowlloing code is used to excute SSIS package from web or windows applications.

First we need to add reference Microsoft.SqlServer.ManagedDTS to the project ( Right click on References. Click on 'Add Reference'. It will pop up Add reference window. select Microsoft.SqlServer.ManagedDTS  under .NET components and click on OK).

HTML Source:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

         <title>Excute SSIS package from .NET application</title>
          <form id="form1" runat="server">
                         <asp:Button ID="btnExcute" runat="server" OnClick="btnPackage_Click" Text="Excute Package" />

C# Code:

protected void btnPackage_Click(object sender, EventArgs e)

          string filename = "C:/Documents/Projects/TestPackage/bin/Deployment/test.dtsx";
          Application app = new Application();
          Package pckg = null;
                  pckg = app.LoadPackage(filename, null);
                  DTSExecResult result = pckg.Execute();
           catch (Exception ex)
                  throw ex;