如何获取解决方案中所有 SSIS 包的所有错误

How to get all errors of all SSIS packages in a solution(如何获取解决方案中所有 SSIS 包的所有错误)

本文介绍了如何获取解决方案中所有 SSIS 包的所有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2015 中,我在 SSIS 包文件夹中有一个包含 3 个 dtsx 的解决方案.我重新构建解决方案并获得成功.只有当我一个接一个地打开一个 dtsx 时,我才注意到其中一些(不是全部)实际上有几个问题.

In Visual Studio 2015 I have a solution with 3 dozens dtsx in the SSIS Packages Folder. I re-build the solution and I get success. Only when I open single dtsx one after the other I notice that some of them (not all), actually, have several problems.

有没有办法在错误列表中获取这些问题的列表,还是需要一个一个打开所有dtsx?

Is there a way to get a list of these problems in the Error List or do I need to open all dtsx one by one?

推荐答案

不幸的是,如果不打开包或使用 DTExec Utility 执行它们,就无法从集成服务解决方案(在 Visual Studio 中)实现这一点.但是您可以采取一些解决方法并以编程方式检查获取错误:

Unfortunately, there is no way to achieve this from your integration services solution (in visual studio) without opening the packages or maybe executing them using DTExec Utility. But you can do some workaround and check get errors programmatically:

解决方法

  1. 我使用 Visual Studio(使用 Vb.Net)创建了一个 winforms 应用程序
  2. 我添加了 Microsoft.SqlServer.DTSPipelineWrapMicrosoft.SQLServer.ManagedDTS 作为参考
  3. 我使用以下代码遍历特定目录中的包、验证并将错误写入日志文件:

  1. I created a winforms application using visual studio (using Vb.Net)
  2. I added Microsoft.SqlServer.DTSPipelineWrap and Microsoft.SQLServer.ManagedDTS as references
  3. I used the following code to loop over packages in a specific directory, validate, and get errors into a log file:

Dim strPackagesDirectory As String = "C:UsersAdminDesktopNew folder"
Dim strOutputLogFile As String = "D:1.txt"

For Each strFile As String In IO.Directory.GetFiles(strPackagesDirectory, "*.dtsx", IO.SearchOption.TopDirectoryOnly)

    Dim pckg As New Microsoft.SqlServer.Dts.Runtime.Package
    Dim app As New Microsoft.SqlServer.Dts.Runtime.Application

    pckg = app.LoadPackage(strFile, Nothing)
    Dim obj = pckg.Validate(Nothing, Nothing, Nothing, Nothing)

    If pckg.Errors.Count > 0 Then

        Using sr As New IO.StreamWriter(strOutputLogFile, True)
            sr.WriteLine("")
            sr.WriteLine(strFile)
            sr.WriteLine("--------------")
            For Each err As Object In pckg.Errors


                sr.WriteLine(err.Description)

            Next

            sr.WriteLine("==========")
            sr.Close()
        End Using

    End If
Next

参考资料

  • https://msdn.microsoft.com/en-us/library/ms136090.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1莉>
  • https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package.aspx
  • https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtscontainer.validate.aspx

这篇关于如何获取解决方案中所有 SSIS 包的所有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何获取解决方案中所有 SSIS 包的所有错误

基础教程推荐