Get DTSx/SSIS Connections From C#

Categories: DatabaseDevelopment Notes; Tagged with: ; @ December 5th, 2012 23:49

Requirement:  Get all connections from dtsx packages using C#.


Using Microsoft.SqlServer.Dts.Runtime to load the package, and then get all connections.

Step1 Add reference

In case you are totally new to .Net/C#, you may need this screen capture:


In the pop-up window, click “Browse” tab, and select: C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Microsoft.SQLServer.ManagedDTS.dll

About the dll path:

ref 1:

ref 2:

Step 2 Coding

import: using Microsoft.SqlServer.Dts.Runtime


        public void testDts()
            string pkgLocation;
            Package pkg;
            Application app;
            DTSExecResult pkgResults;

            pkgLocation =
              @"C:\Users\x\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\" +
            app = new Application();
            pkg = app.LoadPackage(pkgLocation, null);

            Connections conns = pkg.Connections;
            foreach (ConnectionManager cm in conns)
                Console.WriteLine("Name = " + cm.Name + ", HostType = " + cm.HostType + "; ConnectionString=" + cm.ConnectionString);



Name = Flat File Connection Manager, HostType = ConnectionManager; ConnectionString=C:\Users\x\Desktop\ssisTest.txt
Name = x_instan, HostType = ConnectionManager; ConnectionString=Data Source=x-PC\x_INSTAN;Integrated Security=SSPI;Connect Timeout=30;


// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.