开发者

SSIS C# Script task - Can you set a Dts.Variable - Error: The type of the value being assigned to variable differs from the current variable type

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

            public void Main()
{
            s开发者_Go百科tring 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜