SSIS: Throwing errors from script task/component
来源:互联网 发布:淘宝定制类目有多少家 编辑:程序博客网 时间:2024/05/04 22:37
I'm working on a project at the moment that entails making calls to external DLLs from within a script task or script component. In our case the DLL in question is a web service proxy and we've been having numerous problems getting it to work. Being able to grab the errors returned from the WS has been a godsend and to do that I've come up with a bit of code that I thought might be worth sharing.
This is probably fairly noddy to any developers reading this but to those SSIS developers out there who are, like me, still trying to get their head around coding this could prove to be really useful.
All it basically does is catch an exception and recursively loop over any exceptions in the InnerException object(s), throwing out the error messags as error events as it goes. This means that the errors are caught in whatever logging mechanism you happen to be using.
Enough waffling. here's the code for within a script task - and before any developers start to moan at me for not using C# - you should know that VSA (which this is) only supports VB.Net:
Try
'call a method which throws an error
Catch e
Dts.Events.FireError(-1, "", "Unable to solicit web service response: " + e.Message, "", 0)
While Not e.InnerException Is Nothing
e = e.InnerException
Dts.Events.FireError(-1, "", "InnerException: " + e.Message, "", 0)
End While
End Try
The code to use inside a script component is almost identical:
Try 'call a method which throws an error Catch e Me.ComponentMetadata.FireError(-1, "", "Unable to solicit web service response: " + e.Message, "", true) While Not e.InnerException Is Nothing e = e.InnerException Me.ComponentMetadata.FireError(-1, "", "InnerException: " + e.Message, "", true) End While End Try |
All rather simple really. If you use this, let me know how it works for you. And if you have any better ideas - I'm all ears!
-Jamie
UPDATE
Thanks to Graham (see below) who pointed out that using the ToString() method of the exception will contain all of the InnerException messages.
Here's that code then:
Try 'call a method which throws an error Catch e Dts.Events.FireError(-1, "", "Unable to solicit web service response: " + e.ToString(), "", 0) End Try |
I haven't tested that yet but am assuming it works fine!
Thanks Graham!! Goes to show how little I know about .net dev doesn't it?
-Jamie
- SSIS: Throwing errors from script task/component
- SSIS使用Script task处理Active Directory
- SSIS - Script Component, Split single row to multiple rows
- SSIS中通过Script Task发送邮件 Sql2005
- SSIS中通过Script Task发送邮件 Sql2005
- SSIS basic knowledge - logging, script task & file existence checking
- SQL 2005: SSIS – PUSHING DATA TO MYSQL USING SCRIPT COMPONENT DESTINATION
- SSIS之操作Script Component组件的Blob Column类型的处理
- SSIS script task中用代码的方式查询数据库样例
- 微软 BI ssis 中的 script task中用代码直接调用 WCF / Webservice
- SSIS - NoMatchBehavior Error fail Component
- SSIS Component的ValidateExternalMetadata属性
- Script component 用法
- SSIS中ExecuteSQL TASK组件
- SSIS Custom Data Flow Task
- Cheatable XML task in SSIS
- SSIS Execute SQL Task 用法
- SSIS异常--SSIS FTP Task Variable Remote Path invalid
- VC之CString,wchar_t,int,string,char*之间的转换(转帖)
- android学习
- userinit.exe异常的全面解决方案
- 大型网站架构
- What does the D in SDE stand for?
- SSIS: Throwing errors from script task/component
- sql server 2005
- eclipse的ant-ivy和svn更新的网址
- A project with an Output Type of Class Library cannot be started directly
- 学习一些网页布局方面的资料
- DataGridView.CellContentClick 事件的C#例子
- 今天新下载了as3的电子书
- DataGridView的一些技巧
- ZoneAlarm Programs Control List