Referencing variables in a Script Task

  • I am writing a .NET script to email end-of-job notice to my users. In that eoj notice I have to include how many records came from each user. Because multi files can be sent I am using a For Each loop (in my pkg) I am storing the rec count in a variable ("NoInflrecs,NoKCGrecs") one for each user.

    I placed the variables in the ReadOnlyVariables are of the Script Task, and I tried to reference them in the body of the email. However, they are tagged as not being declared. I tried referencing them with the @ sign and without. I tried referencing them like I do in the Email Task (@[User::NoInflrecs]) and still nada. Here is the code

    strBody = "Job completed successfully." + vbCrLf + vbCrLf

    strBody += "Number of Influent Records received today: "

    strBody += Trim(Str(NoInflrecs)) + vbCrLf

    strBody += "Number of KCG Files received today: " + Trim(Str(NoKCGrecs))

    Does anyone have any idea how this s/b done??

    Thank you,

    Trudye

  • trudye10 (8/4/2009)


    I am writing a .NET script to email end-of-job notice to my users. In that eoj notice I have to include how many records came from each user. Because multi files can be sent I am using a For Each loop (in my pkg) I am storing the rec count in a variable ("NoInflrecs,NoKCGrecs") one for each user.

    I placed the variables in the ReadOnlyVariables are of the Script Task, and I tried to reference them in the body of the email. However, they are tagged as not being declared. I tried referencing them with the @ sign and without. I tried referencing them like I do in the Email Task (@[User::NoInflrecs]) and still nada. Here is the code

    strBody = "Job completed successfully." + vbCrLf + vbCrLf

    strBody += "Number of Influent Records received today: "

    strBody += Trim(Str(NoInflrecs)) + vbCrLf

    strBody += "Number of KCG Files received today: " + Trim(Str(NoKCGrecs))

    Does anyone have any idea how this s/b done??

    Thank you,

    Trudye

    Trudye,

    To access the required variable you have to use the special Dts object like this:

    Dts.Variables("NoInflrecs").Value

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • Thank you so much cozyroc I'll try it 1st thing tomorrow! If I can find a minute to breathe.

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

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