I figure out this code when I try to run the .dtsx package from C#.
Quite a prospect, I guess. The .dtsx package (Sql Server Integration Service) itself has open many possibilites to do some ETL and Data Warehousing. I won’t cover the ETL Tutorial with SSIS in this post though, I’m still learning on it.
I just want to share the code I made to run simple .dtsx package. When I try searching the tutorial in http://msdn2.microsoft.com/en-us/library/ms136090.aspx I got some errors when I compiled it, therefore I made some slight changes to make it work:
Here is my code:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
namespace MyConsole
{
class Program
{
static void Main(string[] args)
{
string pkgLocation;
Package pkg;
Application app;
DTSExecResult pkgResults;
pkgLocation =
@”C:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\TheIntegration\TheIntegration\Package.dtsx”;
app = new Application();
pkg = (Package)app.LoadPackage(pkgLocation, true, null);
pkgResults = pkg.Execute();
Console.WriteLine(pkgResults.ToString());
Console.ReadKey();
}
}
}
Please note that the location string is the location of your .dtsx file. One more thing, don’t forget to add Microsoft.SQLServer.DTSRuntimeWrap.dll as reference.
Hope it help!
Recent Comments