Wie man ein SSIS Paket von .NET ausführt?

Ich habe ein SSIS-Paket, das ich gern auch Parameter übergeben möchte, diese Parameter kommen aus einer .NET Applikation (VB oder C #), also war ich neugierig, ob jemand weiß, wie man das macht oder besser noch eine Website mit hilfreichen Hinweisen wie ich es mache Also grundsätzlich möchte ich ein SSIS-Paket von .NET ausführen, das die SSIS-Paketparameter übergibt, die es in ihm verwenden kann. Zum Beispiel wird das SSIS-Paket flache file importieren in eine SQL db aber der Pfad und Name der file könnte der Parameter, der von der .Net-Anwendung übergeben wird.

Hier ist, wie man variables im Paket aus Code setzen –

using Microsoft.Sqlserver.Dts.Runtime; private void Execute_Package() { string pkgLocation = @"c:\test.dtsx"; Package pkg; Application app; DTSExecResult pkgResults; Variables vars; app = new Application(); pkg = app.LoadPackage(pkgLocation, null); vars = pkg.Variables; vars["A_Variable"].Value = "Some value"; pkgResults = pkg.Execute(null, vars, null, null, null); if (pkgResults == DTSExecResult.Success) Console.WriteLine("Package ran successfully"); else Console.WriteLine("Package failed"); } 

Hier geht es mit dem SSDB-Katalog, der mit SQL server 2012 eingeführt wurde …

 using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } mit System.Collections.Generic; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } mit System.Data.SqlClient; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } { using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } { using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } } using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using Microsoft.Sqlserver.Management.IntegrationServices; public List<string> ExecutePackage(string folder, string project, string package) { // Connection to the database server where the packages are located SqlConnection ssisConnection = new SqlConnection(@"Data Source=.\SQL2012;Initial Catalog=master;Integrated Security=SSPI;"); // SSIS server object with connection IntegrationServices ssisserver = new IntegrationServices(ssisConnection); // The reference to the package which you want to execute PackageInfo ssisPackage = ssisserver.Catalogs["SSISDB"].Folders[folder].Projects[project].Packages[package]; // Add a parameter collection for 'system' parameters (ObjectType = 50), package parameters (ObjectType = 30) and project parameters (ObjectType = 20) Collection<PackageInfo.ExecutionValueParameterSet> executionParameter = new Collection<PackageInfo.ExecutionValueParameterSet>(); // Add execution parameter (value) to override the default asynchronousized execution. If you leave this out the package is executed asynchronousized executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "SYNCHRONIZED", ParameterValue = 1 }); // Add execution parameter (value) to override the default logging level (0=None, 1=Basic, 2=Performance, 3=Verbose) executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 50, ParameterName = "LOGGING_LEVEL", ParameterValue = 3 }); // Add a project parameter (value) to fill a project parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 20, ParameterName = "MyProjectParameter", ParameterValue = "some value" }); // Add a project package (value) to fill a package parameter executionParameter.Add(new PackageInfo.ExecutionValueParameterSet { ObjectType = 30, ParameterName = "MyPackageParameter", ParameterValue = "some value" }); // Get the identifier of the execution to get the log long executionIdentifier = ssisPackage.Execute(false, null, executionParameter); // Loop through the log and do something with it like adding to a list var messages = new List<string>(); foreach (OperationMessage message in ssisserver.Catalogs["SSISDB"].Executions[executionIdentifier].Messages) { messages.Add(message.MessageType + ": " + message.Message); } return messages; } 

Der Code ist eine leichte Anpassung von http://social.technet.microsoft.com/wiki/contents/articles/21978.execute-ssis-2012-package-with-parameters-via-net.aspx?CommentPosted=true#commentmessage

Es gibt auch einen ähnlichen Artikel bei http://domwritescode.com/2014/05/15/project-deployment-model-changes/

Um @Craig Schwarze Antwort hinzuzufügen,

Hier sind einige verwandte MSDN Links:

Laden und Ausführen eines lokalen Pakets programmgesteuert:

Laden und Ausführen eines Fernpakets programmgesteuert

Erfassen von Ereignissen aus einem laufenden Paket:

 using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } mit System; using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } { using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } { using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } { using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } } using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } } using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } class Programm using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } { using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } static void Main (string [] args) using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } { using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } } using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } } } using System; using Microsoft.Sqlserver.Dts.Runtime; namespace RunFromClientAppWithEventsCS { class MyEventlistner : DefaultEvents { public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) { // Add application-specific diagnostics here. Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description); return false; } } class Program { static void Main(string[] args) { string pkgLocation; Package pkg; Application app; DTSExecResult pkgResults; MyEventlistner eventlistner = new MyEventlistner(); pkgLocation = @"C:\Program Files\Microsoft SQL server\100\Samples\Integration Services" + @"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"; app = new Application(); pkg = app.LoadPackage(pkgLocation, eventlistner); pkgResults = pkg.Execute(null, null, eventlistner, null, null); Console.WriteLine(pkgResults.ToString()); Console.ReadKey(); } } }