Access to variables in Script Task

  • I have a user variable that is defined at the package level called requestString.

    In my Script Task I added a ReadWriteVariable 'requestString' (without the quotes).

    I then do the following in my code:

    Dim vars As Variables

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

    vars("requestString").Value = "test"

    and I get the following error:

    Error: 0xC001405C at Script Task: A deadlock was detected while trying to lock variables "User::requestString" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.

    Tried all types of things and can't get it to work.

    Any help is appreciated. Thx.

  • Can't have two variables with the same name in the same scope.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • ok...but how do I write to my User::requestString variable?

    Thx.

  • If you search for "SSIS variable" in Books Online, it has data on how to set variable values programmatically, and so on.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • scottpod (1/14/2009)


    I have a user variable that is defined at the package level called requestString.

    In my Script Task I added a ReadWriteVariable 'requestString' (without the quotes).

    I then do the following in my code:

    Dim vars As Variables

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

    vars("requestString").Value = "test"

    and I get the following error:

    Error: 0xC001405C at Script Task: A deadlock was detected while trying to lock variables "User::requestString" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.

    Tried all types of things and can't get it to work.

    Any help is appreciated. Thx.

    Scott,

    If you define a variable in the script dialog, you should not use variable dispenser to access it. Just use the following code to write to the variable:

    Dts.Variables("requestString").Value = "test"

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

  • CozyRoc (1/14/2009)


    Scott,

    If you define a variable in the script dialog, you should not use variable dispenser to access it. Just use the following code to write to the variable:

    Dts.Variables("requestString").Value = "test"

    Ok.....yes got that working. But.... that is like dealing with a local variable (to that script task only)....and I want to populate my package variable instead (so...the global User::variable). I need to initially read a string from a text file.......and then call some custom encryption code which then I need to pass to a web service task via this User::variable.

    This is what I can't figure out how to do. And I can't find any info on it.

    Thanks.

  • scottpod (1/15/2009)


    CozyRoc (1/14/2009)


    Scott,

    If you define a variable in the script dialog, you should not use variable dispenser to access it. Just use the following code to write to the variable:

    Dts.Variables("requestString").Value = "test"

    Ok.....yes got that working. But.... that is like dealing with a local variable (to that script task only)....and I want to populate my package variable instead (so...the global User::variable). I need to initially read a string from a text file.......and then call some custom encryption code which then I need to pass to a web service task via this User::variable.

    This is what I can't figure out how to do. And I can't find any info on it.

    Thanks.

    Not true. You can access the global variables exactly the same way, too.

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

  • Not sure why it wasn't working.....but I ended up deleting my package variables and re-creating them. And now it works. Go figure!

    Thanks CozyRoc!!

Viewing 8 posts - 1 through 7 (of 7 total)

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