William

My feedback

  1. 90 votes
    Sign in
    (thinking…)
    Sign in with: Microsoft
    Signed in as (Sign out)

    We’ll send you updates on this idea

    under review  ·  17 comments  ·  SQL Server » Bugs  ·  Flag idea as inappropriate…  ·  Admin →
    William commented  · 

    OK - I don't know how to solve it, but I found a workaround, if somebody maybe interested:
    1. instead of having script task, use Execute Package Task.
    2. Put your script task into new package (just one task in the package), create parameters that your parent package is going to supply when calling it.
    3. In your script, add lines to assign values to your Parent package (child package has access to your parent package variables at runtime). Btw, you don't need to specify any read-only, read-write variables in the GUI of the script task. use the following template in the script:
    public void Main()

    {
    Variables vars = null;
    VariableDispenser variableDispenser = Dts.VariableDispenser;
    variableDispenser.LockForWrite("User::ParentPackageVariable");
    variableDispenser.LockForRead("User::ChildPackageVariable");
    variableDispenser.GetVariables(ref vars);

    vars["User::ParentPackageVariable"].Value = "new value"; //whatever your code does

    vars.Unlock();

    Dts.TaskResult = (int)ScriptResults.Success;
    }

  2. 79 votes
    Sign in
    (thinking…)
    Sign in with: Microsoft
    Signed in as (Sign out)

    We’ll send you updates on this idea

    25 comments  ·  SQL Server » Bugs  ·  Flag idea as inappropriate…  ·  Admin →

    Upvotes: 47

    <=-=Jun 26 2017 1:02AM=-=>

    I have had the exact same issue, intermittently whenever I open script tasks all my code seems to have vanished and all the “ReadOnlyVaraiables” and “ReadWriteVariables” have also disappeared. It happens for c# and VB script tasks. This is is extremely frustrating and is impossible to develop a project when code randomly keeps disappearing. I’m wondering if this is a bug with Visual Studio 14.0.23107.0 D14REL. Can anyone at Microsoft shed some light on this please?

    <=-=Jun 29 2017 10:45PM=-=>

    Got the same problem. Seems like the Script Task is cleared when the project/Visual Studio i closed/shut down.

    <=-=Jul 18 2017 5:38PM=-=>

    Same problem for me, too. Once the original code in Script Task was still present after reloading the solution. But after that they are gone, along with ReadOnly/ReadWriteVariables and ConnectionManagers. I’m using SSDT 14.0.61705.170 (which just came out) with VS 14.0.25431.01 update…

    William commented  · 

    OK - I don't know how to solve it, but I found a workaround, if somebody maybe interested:
    1. instead of having script task, use Execute Package Task.
    2. Put your script task into new package (just one task in the package), create parameters that your parent package is going to supply when calling it.
    3. In your script, add lines to assign values to your Parent package (child package has access to your parent package variables at runtime). Btw, you don't need to specify any read-only, read-write variables in the GUI of the script task. use the following template in the script:
    public void Main()

    {
    Variables vars = null;
    VariableDispenser variableDispenser = Dts.VariableDispenser;
    variableDispenser.LockForWrite("User::ParentPackageVariable");
    variableDispenser.LockForRead("User::ChildPackageVariable");
    variableDispenser.GetVariables(ref vars);

    vars["User::ParentPackageVariable"].Value = "new value"; //whatever your code does

    vars.Unlock();

    Dts.TaskResult = (int)ScriptResults.Success;
    }

Feedback and Knowledge Base