如何获取解决方案中所有 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 包的所有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)