How to assign a value to global variable

  • Hi

    I am using Script task to assign a value to global variable.I am trying in this way

    Dts.Variables("gvRunDt").Value = RunDt

    Dts.Variables("gvPdDt").Value = PdDt

    Dts.Variables("gvFileName").Value = StrFile

    Here gvRunDt,gvPdDt,gvFileName,gvFilename are global variables ......i want to assign the value in run time.............

    Thanks in Advance...........

  • Make sure that you have specified these variables in the ReadWrite varible list under Script tab in Script Task Editor. The list should be comma seperated - e.g. gvRunDt,gvPdDt,gvFileName

  • I did that But still i am unable to assign the values

  • Maybe try this?

    Imports Microsoft.SqlServer.Dts.Runtime

    Public Class ScriptMain

    Public Sub Main()

    Dim vars As Variables

    Dts.VariableDispenser.LockOneForWrite("vMyVar", vars)

    vars(0).Value = "Hello World"

    vars.Unlock()

    Dts.TaskResult = Dts.Results.Success

    End Sub

    End Class

    [font="Courier New"]ZenDada[/font]

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

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