如何在尝试执行时了解SSIS运行包问题

时间:2017-05-26 15:42:19

标签: sql-server ssis etl ssis-2012

我尝试使用这段代码运行SSIS:

public class EjecutaPaquete {

     private Microsoft.SqlServer.Dts.Runtime.Package pkgPaquete;
     private Application appAplicacion;

     public DTSExecResult EjecucionPaquete(string str_Paquete, List < CatVariablesEtl > Vars = null) {

       DTSExecResult respuesta;
       try {
         appAplicacion = new Application();

         appAplicacion.PackagePassword = "mypass";

         pkgPaquete = appAplicacion.LoadPackage(str_Paquete, null);

         foreach(CatVariablesEtl item in Vars) {
           pkgPaquete.Variables[item.str_NombreVariable.ToString()].Value = item.str_ValorVariable.ToString();
         }

         respuesta = pkgPaquete.Execute();

         return respuesta;
       } catch (Exception ex) {

         throw new NotImplementedException();
       }

     }

它正确地将所有变量读入foreach,问题是当尝试执行包respuesta = pkgPaquete.Execute();时首先它返回succeeded但是当它返回“respuesta”时它得到failure

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以从package.Errors属性中读取错误:

代码示例:

foreach(DtsError item in package.Errors) {

     Console.Writeline(item.description);

}