SSIS 包错误 - 通过 C# 控制台应用程序执行

本文关键字:通过 控制台 应用程序 执行 包错误 错误 SSIS | 更新日期: 2023-09-27 18:35:02

我是这个线程的新手,我陷入了需要通过 C# 控制台应用程序执行 SSIS 包的情况。

以下是我用来执行包的代码。

Package pkg;
Application app;
DTSExecResult pkgResults;
pkgLocation =@"D:'MIS Reports'TERADATA'Daily_CBASQ1_Loading.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();

但它抛出了一个错误:

The package failed to load due to error 0xC0011008 
"Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored." 

CPackage::LoadFromXML fails

请帮忙!

SSIS 包错误 - 通过 C# 控制台应用程序执行

这更像是注释,但想发布可能有助于调试的代码

您可以添加事件侦听器,这可以帮助您捕获实际错误。

  class MyEventListener : DefaultEvents
      {
        public override bool OnError(DtsObject source, int errorCode, string subComponent, 
          string description, string helpFile, int helpContext, string idofInterfaceWithError)
        {
          Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
          return false;
        }
      }

现在像这样调用包并更新有问题的实际错误

 MyEventListener eventListener = new MyEventListener();
pkgLocation =@"D:'MIS Reports'TERADATA'Daily_CBASQ1_Loading.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, eventListener);
pkgResults = pkg.Execute(null, null, eventListener, null, null);

请在下面找到我的代码:

    static void Main(string[] args)
    {
        string pkgLocation;
        Package pkg;
        Application app;
        DTSExecResult pkgResults;
        MyEventListener eventListener = new MyEventListener();

        pkgLocation =@"D:'MIS Reports'TERA DATA'Daily_CBASQ1_Loading.dtsx";
        app = new Application();
        pkg = app.LoadPackage(pkgLocation,eventListener);
        pkgResults = pkg.Execute();
        Console.WriteLine(pkgResults.ToString());
        Console.ReadKey();
    }
}
class MyEventListener : DefaultEvents
{
    public override bool OnError(DtsObject source, int errorCode, string subComponent,
           string description, string helpFile, int helpContext, string idofInterfaceWithError)
    {
        // Output Error Message
        Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
        return false;
    }
}

错误:

由于错误0xC0010014"发生一个或多个错误,包加载失败。在此错误之前应该有更具体的错误来解释错误的详细信息。此消息用作遇到错误的函数的返回值。当 CPackage::LoadFromXML 失败时,会发生这种情况。