back to top

Running Sql Server Integration services package from a C Sharp application

If you’ve ever created a SSIS package and wanted to provide a way for end users to run that package without having to run the Business Intelligence Development studio, you can compile the package into a dtsx file for them to run.  This would require them to manually alter connections and variables, which can get complicated for an average end user. Alternatively, it is pretty simple to put together an application which can be used to run the package.  This would allow you to handle modifications to package variables in a much more user-friendly manner.

I have a relatively simple SSIS package which queries data from a view based on a date range, and exports the returned data to a CSV file.

First of all, you will need to add a reference to the Microsoft.SQLServer.ManagedDTS.dll as well as a reference to the Microsoft.SqlServer.DTS.Runtime namespace.  Once that is done, you can reference the namespace to create objects referencing the package, and any other items you need to reference such as connections and variables.

This is a simple method I created in Visual Studio 2010 which calls the provided compiled DTS package and updates the connections and variables. (see the attached ZIP file to see the full application)

 
using Microsoft.SqlServer.Dts.Runtime;

namespace CFX_ExportPortalEmailLeads
{
public partial class frmExportData : Form
{

private void cmdRun_Click(object sender, EventArgs e)
{
Execute_Package(String.Format("{0:yyyy-MM-dd}", dtpStartDate.Value), String.Format("{0:yyyy-MM-dd}", dtpEndDate.Value));
}

private void Execute_Package(string StartDate, string EndDate)
{
string pkgLocation = txtUsePackage.Text;

Package pkg;
Microsoft.SqlServer.Dts.Runtime.Application app;
DTSExecResult pkgResults;
Variables vars;
Connections conns;

app = new Microsoft.SqlServer.Dts.Runtime.Application();
pkg = app.LoadPackage(pkgLocation, null);

//Set Connection Settings
conns = pkg.Connections;
conns["DestinationConnectionFlatFile"].ConnectionString = txtOutputFolder.Text + "\ExportFile.csv";
conns["SourceConnectionOLEDB"].ConnectionString = "Data Source=DataServer;User ID=sa;Password=1234567;Initial Catalog=DTSDatabase;Provider=SQLOLEDB;Auto Translate=false;";

//Set SSIS Variables
//**Note** - Variables MUST be package level variables in the SSIS package, otherwise an error will result when trying to set the variable
vars = pkg.Variables;
vars["StartDate"].Value = StartDate;
vars["EndDate"].Value = EndDate;

pkgResults = pkg.Execute(null, vars, null, null, null);

if (pkgResults == DTSExecResult.Success)
MessageBox.Show("Package Ran Successfully");
else
MessageBox.Show("Package Failed");

}

}
}

As you can see, this method is pretty simple, but provides a much simpler user interface than the compiled SSIS package.

 

Thanks for reading!

 

 

 

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Jason Buss
Jason Buss
Jason is a senior application developer with Customer FX.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos