On Error Event handler in For Each Loop Container

  • I have a For Each Loop Container that iterates through a list of servers in my environment. Usually it is used to gather information from each of the servers. Inevitably there are a few errors. But my error handler does not write the name of the Server at which the error occurred. Here is my expression:

    "INSERT INTO ErrorLog2 VALUES (' "+ @[System::PackageID] +" ' , ' "+ @[System::PackageName] +" ',' "+@[System::MachineName]+" ',' "+@[System::TaskName] +" ',' "+(DT_WSTR,50)@[System::ErrorCode] +" ',' "+@[System::ErrorDescription] +" ',GETDATE())"

    I cannot figure out how to add the name of the server that caused the error.

    Help? Anyone?

  • Is there a user variable for the server name in the variable mapping tab of the for each loop container? If so you should be able to include it in the logging insert.

  • Yes.

    I have been unsuccessful using it with my expression.

  • In what way is it unsuccessful? Is it empty? or does it fail?

    At what level is your event handler? if it is at the package level, rather than at the for each loop level it's possible the variable scope is too narrow to be read by the event handler. I have had trouble with losing track of where I created event handlers in the past.

    I would try creating another variable scoped at package level. Within the event handler add an expression task that sets the new variable to the User::ServerName variable and then click Evaluate. This should either show you the value (empty or default) or provide an error message.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply