Create and use a C# Assembly for SSIS

Article Index
Create and use a C# Assembly for SSIS
Page 2
Page 3
All Pages

Here's how to create a C# class library in Visual Studio and invoke it from an SSIS script component (using just the teensy weensiest bit of VB.Net code):

 

Creationalist Assemblage

(Huh huh... see my article on the Flying Spaghetti Monster

 

When you have become weary of the world and are tired of crap programming languages like VB, but you need to write a complicated piece of logic for SSIS, you may consider going down the route of programming it in an eloquent programming like C#.

 

Download the example code.

 

Create a C# class library project

 You're using Visual Studio 2005, right? Create a new project - go: File -> New -> Project and choose the type of project that you want to build:

 

Image

 

Chuck some code in

 Rename your class to something useful (I called it StringUtils here) and add your clever bit of code in:

 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace SSISClassLib {
  6.   public class StringUtils {
  7.     public static string InitCap(string input) {
  8.       string s = input.ToString();
  9.       s=s.Substring(0,1).ToUpper()+s.Substring(1);
  10.       int len = s.Length;
  11.       int pos = s.IndexOf(' ');
  12.       while(pos!=-1 && pos < (len-1)) {
  13.         if(pos == (len -1)) {
  14.           s = s.Substring(0,pos) + s.Substring(pos + 1,1).ToUpper() + s.Substring(pos + 1);
  15.         } else {
  16.           s = s.Substring(0,pos + 1) + s.Substring(pos + 1,1).ToUpper() + s.Substring(pos + 2);
  17.         }
  18.         pos = s.IndexOf(' ',pos+1);
  19.       }
  20.       return s;
  21.     }
  22.   }
  23. }