Archive for April, 2009

Executing A SSIS Package From C#

This is something interesting that i had to do recently and i though i should share it.

The idea behind this is that SSIS is a freaking powerful tool and since its so powerful why go write another app to do exactly what it can already do.BTW if you have not used it (which is kinda hard if you are a windows developer) then i suggest you go look it up and get a taste of what you have been missing.

So the main reason i use it and i am sure the same reason a lot of other people use it is to run data imports into a sql server. Now a common problem that you will run into is if you have to import data from a Excel Worksheet. Since the location of the work sheet can change (especially if some one else needs to run the import) you need to either change the location manually , force the user to only use one location or add some VBScripting to prompt for a path.

The problem is that VB scripting is one of the most annoying languages i have ever tried to write a program in and i figured that you must be able to do this in C# somehow.

So first things first , you need to add a reference to Microsoft.SQLServer.ManagedDTS . Note that you will most likeley not find this in the default .Net Import list and you will have to manually find the dll so that it can be imported.

Once the reference has been added the code below will execute the package of your choice.

Application pacApp = new Application();

Package packLoader = pacApp.LoadPackage(System.Windows.Forms.Application.StartupPath+@”\WorkflowImport.dtsx”,
null);
packLoader.Connections["SourceConnectionExcel"].ConnectionString
= @”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=”+txtFileName.Text+”;Extended Properties=EXCEL 8.0;HDR=YES;”;
DTSExecResult pacResult = packLoader.Execute();
MessageBox.Show(pacResult.ToString());

What the code above does is pretty simple but it makes all the difference to the user.

  1. First it creates a instance of the SSIS application.
  2. It then creates a new package and initializes it using the app instance created in the previous step.It should be noted that because the package is deployed with the app it resides in the exe’s directory and you have to manually find the directory and load it from there.
  3. Once the package is loaded we change the path of the Excel Connection to a new one that has been entered in a text box on the form.
  4. Finally the package is executed and the result stored and then displayed using a message box.

And thats all there is to it , this allows you to make a pakage a lot simpler to use and provides you with a host of other options not discussed here.

As always let me know what you think

~stalkerh

Can management be cut loose

So i have been addicted to a book written by W. E. Pete Peterson. The name of the book is Almost Perfect and while its very old it does make for some really good reading as it gives some good insight into the rise of a company.

To those of you that cant get access to the book in its printed form you can read it online for free (yes its legal).
[...]

Blast from the past

So ID just released a awesome video of the studio etc just about the time before doom was released and man does it bring back some memories.

Catch the vid here

Xbox Awards

timthumb2php

Microsoft has their own Oscars for Xbox Live titles, well sort off. In the second annual community voting for which titles are the most favourite and in which categories the results are as follows:

Game of the Year
Castle Crashers

Best Versus Mode
Super Street Fighter II Turbo HD Remix

Best Single Player Game
Portal: Still Alive

Best Remake
Super Street Fighter II Turbo HD Remix

Best Original Game
Castle Crashers

Best Innovation
Braid

Best Graphics
Super Street Fight II Turbo HD Remix

Best Family Game
A Kingdom for Keflings

Best Co-op Mode
Castle Crashers

Castle Crashers walked away with a surprising 3 awards, which we presume is due to the patch that was released not too long ago by The Behemoth might have had an impact as it has apparently sorted out many bugs. Castle Crashers a personal favourite and awesomely fun game to play as a group and to play alone, with the amount of content to find and unlock the replayability is there.

Source: Joystiq.com

FireStats icon Powered by FireStats