Jamie,
I finally found a way to do what I need.
Thanks to J. Welch and his blog (http://agilebi.com/cs/blogs/jwelch/archive/2008/01/15/handling-multiple-errors-in-ssis-revisited.aspx).
I found that when OnError the ErrorCode and ErrorDescription really usefull is the first one raised.
For example :
[Data Conversion [70]] Error: Data conversion failed while converting column ...
is more usefull for than
[DTS.Pipeline] Error: SSIS Error Code DTS_E_THREADFAILED
So I used the piece of code of JWelch to store all the ErrorCodes and ErrorDescirptions in ObjectType variables and then affect the first value of these ones to variables that I pass as parameter to my sp for logging.
Here's the code :
Variables :
errorMessages,errorID both of ObjectType
L_STATUS_VALUE Int32
L_LOAD_MESSAGE String
ScriptTask :
ReadOnlyVariables : System::ErrorCode, System::ErrorDescription
ReadWriteVariables : User::errorMessages,User::errorID,User::L_STATUS_VALUE, User::L_LOAD_MESSAGE
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dim status As Collections.ArrayList
Dim messages As Collections.ArrayList
Try
status = CType(Dts.Variables("User::errorID").Value, Collections.ArrayList)
messages = CType(Dts.Variables("User::errorMessages").Value, Collections.ArrayList)
Catch ex As Exception
status = New Collections.ArrayList()
messages = New Collections.ArrayList()
End Try
status.Add(Dts.Variables("System::ErrorCode").Value.ToString())
Dts.Variables("User::errorID").Value = status
messages.Add(Dts.Variables("System::ErrorDescription").Value.ToString)
Dts.Variables("User::errorMessages").Value = messages
Dts.Variables("User::L_STATUS_VALUE").Value = CInt(status(0))
Dts.Variables("User::L_LOAD_MESSAGE").Value = CStr(messages(0).ToString())
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
Hope it will helps.
Cheers,
Bertrand