Click here to Skip to main content
15,902,198 members
Articles / Programming Languages / C#
Article

Get list of SSIS package and execut, from .NET application

Rate me:
Please Sign up or sign in to vote.
1.90/5 (6 votes)
8 Oct 20062 min read 82.2K   26   9
This article will drive you, how to get list of SSIS packages and executing them using .NET assemblies

Introduction

Hi All,<o:p>

<o:p> 

Here is some cool stuff to call SSIS package from .NET application.<o:p>

Usually SSIS packages deployed on SQL Server or may resides on file system as .dtsx file. General scenario to execute SSIS Package is to deploy on SQL Server and then attach Schedule to it for execution. But some times client may ask to execute SSIS package through user interface, since no technical knowledge required for connecting to SQL Server…?  Finding SSIS package on SQL Server…? And executing SSIS package from SQL Server…?<o:p>

Now questions are, 

How to get list of SSIS packages deployed on SQL Server…?

How to execute SSIS package manually…?<o:p>

What follow is answers to above questions,<o:p>

1.      Import following assemblies to your application<o:p>

System.Data.SqlTypes;<o:p>

Microsoft.SqlServer.Dts.Runtime;<o:p>

Microsoft.SqlServer.Management.Smo;<o:p>

Microsoft.SqlServer.Management.Smo.Agent;<o:p>

Microsoft.SqlServer.Management.Common;<o:p>

System.Data.SqlClient;<o:p>

2.      Add following segment of code which will return collection of SSIS packages deployed on SQL Server<o:p>

Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();<o:p>

<o:p> 

PackageInfos pInfos = app.GetPackageInfos("\\", ConfigurationSettings.AppSettings["ServerIp"].ToString(), "", "");<o:p>

   * ServerIp is subjected to SQL Server IP address                             <o:p>

3.      Now we will add package info (here name of SSIS Package) to drop down list, so that user can select SSIS package and execute the same.<o:p>

       foreach (PackageInfo pInfo in pInfos)<o:p>

                    {<o:p>

                        <o:p>

    if (pInfo.Name != "Maintenance Plans")<o:p>

                            ComboBoxJob.Items.Add(pInfo.Name);<o:p>

<o:p> 

                 } <o:p>

4.      Following code segment shows you how to execute package. This code segment will get invoked when user will click “Execute” button shown at screen shots.<o:p>

        Microsoft.SqlServer.Dts.Runtime.Application app;<o:p>

        app = new Microsoft.SqlServer.Dts.Runtime.Application();<o:p>

            <o:p>

  DTSExecResult pkgResults_Sql;<o:p>

<o:p> 

        Package pkgIn = new Package();<o:p>

<o:p> 

pkgIn = app.LoadFromSqlServer("\\"+ComboBoxJob.SelectedItem.            ToString().Trim(),ConfigurationSettings.AppSettings["ServerIp"].ToString(), "", "", null);<o:p>

     pkgResults_Sql = pkgIn.Execute();<o:p>

     //Message box will show either Success/Failure <o:p>

     MessageBox.Show(pkgResults_Sql.ToString());   <o:p>

5.      For performing the entire functionality user must have respective permission on MSDB database.<o:p>

     Following figures shows how application looks like.

     Sample screenshot

Dropdown list is filled by SSIS packages present on SQL Server as shown below,

Sample screenshot

<o:p>

<o:p>

7.      Select the package and execute the same by clicking execute button.<o:p>

Note – To deploy SSIS Package on SQL Server, check my article “Deploy SSIS Package on SQL Server” 

This article will drive you, how to get list of SSIS packages and executing them using .NET assemblies<o:p>

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
I am a .NET developer cum designer. I work for Zensar Technologies Ltd. Pune (INDIA), I consult, I develop, I debug and besides that I speak at conferences and user groups and I also write. I have written some articles on WCF, WF, SSIS, Compression decompression, CLR Store Procedure, SQL Server Reporting Services 2005, Extended grid and lot more to count.
Reach to me on:-a.malpani@zensar.com

Comments and Discussions

 
GeneralGood Article , minor change Pin
subbaraokv2377-Jul-09 8:06
subbaraokv2377-Jul-09 8:06 
Questionany updates please ?? Pin
kiquenet.com16-Dec-08 22:39
professionalkiquenet.com16-Dec-08 22:39 
Generalhi Pin
aminedsi15-Sep-08 3:05
aminedsi15-Sep-08 3:05 
QuestionSSIS using Sharepoint source and trying to deploy to another server Pin
notes4we11-Sep-08 3:45
notes4we11-Sep-08 3:45 
QuestionHow I can execute SSIS package using c#.net (2.0) (using com object) ? Pin
Paresh Gujarathi10-Jul-08 21:58
Paresh Gujarathi10-Jul-08 21:58 
GeneralNice introduction! Pin
Lorenzo Consegni27-Sep-07 20:59
Lorenzo Consegni27-Sep-07 20:59 
Quite short and simple... that's the introduction i was looking for.
GeneralDTS in SQL Server 2005 Pin
ctuzzolino14-Sep-07 2:14
ctuzzolino14-Sep-07 2:14 
QuestionHow to get execution progress ? Pin
Gil Seagal5-Sep-07 6:52
Gil Seagal5-Sep-07 6:52 
QuestionIs there an article that shows this in VB.NET? Pin
FreeDesign2-Sep-07 7:50
FreeDesign2-Sep-07 7:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.