tags:

views:

3093

answers:

1

My variable is a string at the package level and have added it as readwritevariable example:

            public void Main()
{
            string sServer = "localhost";
            Dts.Variables["User::sourceServer"].Value = sServer;
}

will result in Error: The type of the value being assigned to variable differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

A: 

If you've verified that the variable is indeed a string at the package level, ensure that there are no other variables with a narrower scope that might have a different type. If you have a variable scoped to the script task, or a container that the script task is in, SSIS will use that variable instead of the package-level variable.

You can check this in the designer by clicking on the script task, and ensuring that a new variable doesn't appear in the variable toolbar.

Ryan Brunner