The type of the value being assigned to variable "User::ImportType" differs from the current variable type.

  • I have a package level variable called "User::ImportType" with a data type of int16. Inside a ForEach loop, I'm looking at a filename to determine which Import Flow to branch to using a script:

    public void Main()

    {

    Dts.Variables["ImportType"].Value = null;

    string fileName = Dts.Variables["FileName"].Value.ToString().ToUpper();

    if(fileName.Contains("CLAIMS"))

    Dts.Variables["ImportType"].Value = 0;

    else if(fileName.Contains("MEMBERS"))

    Dts.Variables["ImportType"].Value = 1;

    else if (fileName.Contains("PROVIDERS"))

    Dts.Variables["ImportType"].Value = 2;

    if(Dts.Variables["ImportType"].Value != null)

    Dts.TaskResult = (int)ScriptResults.Success;

    Dts.TaskResult = (int)ScriptResults.Failure;

    }

    When I run the package in the debugger I'm getting the following error message:

    Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The type of the value being assigned to variable "User::ImportType" differs from the current variable type. Does anyone have any ideas where my data type mismatch could be happening?

  • When the Variable is an int16 and I try

    Dts.Variables["Variable"].Value = 1;

    I get the same error.

    When in the SSIS Script task Editor hover your cursor over the "1" and it says Struct System.Int32. Looks like the Script is interpreting that as an int32, and does not want to do an implicit conversion. I quickly looked and couldn't find exactly why.

    If you chage it to

    Dts.Variables["Variable"].Value = (Int16)1;

    it works fine.

    I'll post back if I can find the exact reason.

Viewing 2 posts - 1 through 1 (of 1 total)

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