Solved

Sql Server 2008 SSIS c# packages

Posted on 2009-04-08
4
1,164 Views
Last Modified: 2013-11-10
I'm new to the Microsoft development world (*nix background) and especially green to the C# language. My new job is a Microsoft shop and I have to write these SSIS packages on a SQL Server 2008 installation. I'm writing packages that use a table to obtain their configuration values such as source database, destination database, destination flat file names, etc... That way packages get shared and it cuts down on the redundant packages.

Anyway long story short, I have some proprietary "cleanup" algorithms I've written and each of the shared packages need, such as validating a date range, integers, floating points, string cleanup, etc.... Instead of copying/pasting these methods into every class, I'd like to be able to write these cleanup routines into a separate class and separate file and "include" them into the shared packages so the code is in one centralized location. How would I do that and can you post a code example of how I would include a use one of the 'included' methods? I've posted a pseudo-code example of what I had in mind.
//external library
 

public class nefec_packageValidation {

      public function isValidDateRange(arg1, arg2) {

            /*

                  code here, return boolean

            */

      }
 

      public function isValidFloat(arg1) {

            /*

                  code here, return boolean

            */

      }

}
 
 

//SSIS package Script Component to validate a 'row'

include externalLibrary
 

public override void Input0_ProcessInputRow(Input0Buffer Row){

      Row.column1 = (nefec_packageValidation.isValidFloat(Row.column1) == true) ? Row.column1 : null;

}

Open in new window

0
Comment
Question by:MMDeveloper
  • 3
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24097198
u can create these methods in a class and then inherit that calss for all the other classes
public class CommonMethods

{

public void MethodA(){}

public void MethodB(){}

public void MethodC(){}

}
 

public class Package1:CommonMethods

{}

public class Package2:CommonMethods

{}

Open in new window

0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 24097242
or make those methods static and then call those methods in the specified class
namespace a

{

public class CommonMethods

{

public static bool isValidFloat(){}

public static void MethodB(){}

public static void MethodC(){}

}

 }

using a;
 

public class Package1

{

public override void Input0_ProcessInputRow(Input0Buffer Row)

{

      Row.column1 = (nefec_packageValidation.isValidFloat(Row.column1) == true) 

}

Open in new window

0
 
LVL 15

Author Comment

by:MMDeveloper
ID: 24099850
ok but where would I save the .cs file that has the namespace code in it? This code is being shared amongst several independent packages and projects/solutions (all on the same box). I would assume that in order to do the "using a", that the "a" namespace would have to be saved in a special location
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 24104251
u shud make that into a dll and then refer that dll wherever u want to use it
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SLQ View not updating 10 46
MS SQL 2014 get SPIDs of users 6 25
Usage Scenarios for Extended Events? 1 9
Mssql SQL query 14 27
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now