I seem to be doing something wrong I have a script task as follows:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dim emptyBytes(0) As Byte
Dts.Log("The change in records between this load and the last load is " & CDbl(Dts.Variables("percent").Value) * 100 & "%.", 0, emptyBytes)
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
I have logging turned on for the package going to a text file with just errors checked. For this step I specifically checked the box for logging on this step (instead of inheriting logging) checked the logging provider, and on details checked ScriptTaskLogEntry.
The upshot is, the step runs fine but I have no entry in the log. HELP
Thanks,
LarryC
Well I guess I was wrong It is logging just fine. I kept looking in the Execution Results for the message and it wouldn't show up. Is there a way to get the message in the Execution Results?
Try using FireInformation (Dts.Events.FireInformation)
|||
Smokin! For what I was doing that worked really great. I had a step I wanted to fail the package and I wanted to see the reason I was failing the package. Using the FireError method accomplished both things I wanted: To be able to see the message in progress when interactively running, and to see the message in the log.
As an unexpected bonus, I can log failure messages now without resorting to special considerations with logging. My script task can now inherit package events which are just logging errors Thanks a million.
The syntax I used for anyone else having a similar problem is:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dim emptyBytes(0) As Byte
Dim msg As String = "The change in records between this load and the last load is " + CStr(CDbl(Dts.Variables("percent").Value) * 100) + "%."
Dts.Events.FireError(0, "Fail Package", msg, "", 0)
Dts.TaskResult = Dts.Results.Failure
End Sub
End Class
LarryC
No comments:
Post a Comment