Windows Forms and SSIS package execution

Prerequisites:

  • SQL SERVER SSIS Package
  • Visual C# Express Edition

File Name: Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Agent;
using Microsoft.SqlServer.Management.Common;
using System.Data.SqlClient;
namespace SSIS_Button_Application
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
        private void Button1_Click(object sender, EventArgs e)
        {
            // Load package from file system
            Package package = app.LoadPackage("c:\\Folderpath\\filename.dtsx", null);
            package.ImportConfigurationFile("C:\\folderpath\\filename.dtsConfig");
            Variables vars = package.Variables;
            vars["variablename used in table"].Value = "user variable value";
            DTSExecResult result = package.Execute();
            Console.WriteLine("Package Execution results: {0}", result.ToString());
        }
    }
}

Voila you have your official first .dtsx job executed once you compile your c# code. GOOD LUCK GUYS. Ofcourse this is just a starting point. You can build your own sweet and big application very easily. God be with you all.