Day 2 – My First Executable

Today, we will build a simple executable that will open the test package. For testing purposes, as well as for many scheduling utilities, we will be building a command line executable. The executable will  accept the package path  as an input parameter. Other features will be added in later days, but today we are starting small.

The first step is to create a console application in Visual Studio named SSISRunner.

New_project_screen
Reference

Visual Studio does not automatically create references to the required DLL’s for this solution. You will need to manually add a reference to Microsoft.SQLServer.DTSRuntimeWrap which was located in C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\ Microsoft.SQLServer.ManagedDTS.dll on my machine. The easiest way to ensure that all required components are available on your machine is to install the version of SQL server that you wish to target and include the SDK.

Once referenced, you can use it your program:
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Design;

Code

Now, the easy part. Since the package is saved as file, opening the package is a simple call to Application.LoadPackage. Your code should look similar to this:

namespace SSISRunner

{

class Program

{

static void Main(string[] args)

{

string PackagePath = “”

Application app = new Application();

Package pkg;

//Get the path from the command line arguments

try

{

PackagePath = args[0].ToString();

}

catch (Exception EX)

{

Console.WriteLine(“USAGE:   SSISRunner <PackagePath>”);

}

//Open the package

if (PackagePath != “”)

{

pkg = app.LoadPackage(PackagePath, null);

}

}

}

}

Build

Build the application by pressing F6. This will create the executable in the C:\DOC\SSISRunner\SSISRunner\bin\Debug directory. This portion of the process can be the most confusing part. I am not an expert on Visual Studio or .Net. Assistance from professionals more knowledgeable than myself (of which there are many) may be required to get the application to compile for the first time. Now the good news: once the application compiles and is able to execute without errors, the rest will be easy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s