如何获得解决方案中所有SSIS包的所有错误 [英] How to get all errors of all SSIS packages in a solution
问题描述
在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:
解决方法
- 我使用Visual Studio(使用Vb.Net)创建了一个winforms应用程序
- 我添加了
Microsoft.SqlServer.DTSPipelineWrap
和Microsoft.SQLServer.ManagedDTS
作为参考 -
我使用以下代码遍历特定目录中的程序包,进行验证并将错误获取到日志文件中:
- I created a winforms application using visual studio (using Vb.Net)
- I added
Microsoft.SqlServer.DTSPipelineWrap
andMicrosoft.SQLServer.ManagedDTS
as references 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:\Users\Admin\Desktop\New 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/zh-cn/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
- 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包的所有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!