Advertisement
paulogp

SSIS: Correr um SSIS a partir de um Script Task (v 1.0.1)

Jul 13th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. /* Exemplo de como chamar um SSIS e verificar se correu correctamente usando o componente Script Task */
  2.  
  3.  
  4. using System;
  5. using System.Data;
  6. using Microsoft.SqlServer.Dts.Runtime;
  7. using System.Windows.Forms;
  8.  
  9. namespace ST_6e1eb220f56e42238b2dd7e133b691d7.csproj {
  10.     [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
  11.     public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {
  12.         #region VSTA generated code
  13.         enum ScriptResults {
  14.             Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
  15.             Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
  16.         };
  17.         #endregion
  18.  
  19.  
  20.         public void Main() {
  21.             // declare and instantiate a new DTS application
  22.             Microsoft.SqlServer.Dts.Runtime.Application application = new Microsoft.SqlServer.Dts.Runtime.Application();
  23.  
  24.             // declare a DTS package and import a saved package file
  25.             string the_path = "D:\\services_2011\\indicadores_gerais\\indicadores_gerais\\Package1.dtsx";
  26.             Package the_package = application.LoadPackage(the_path, null);
  27.  
  28.             // handle possible errors
  29.             try {
  30.                 // declare DTS result, and execute it
  31.                 DTSExecResult the_result = the_package.Execute();
  32.             } catch(DtsException the_exception) {
  33.                 MessageBox.Show("The following error ocurred: " + the_exception.Message);
  34.             }
  35.  
  36.             Dts.TaskResult = (int)ScriptResults.Success;
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement