2
votes

I am using VS 2008

so I have two variables count_a and count_b declared as Int32 variables in the package scope I have added the two variables in the ReadOnlyVariables list of the Script Task Editor

my code inside the script task looks like this:

        if (Dts.Variables["count_a"].Value == Dts.Variables["count_b"].Value)
        {
             //do something
        }
        else
        {
             //do something
        }

the default value for both variables is zero. when I step through the code I see that both variables have a zero value but when evaluating this expression: Dts.Variables["count_a"].Value == Dts.Variables["count_b"].Value

I get a false

any one seen anything like this before

appreciate any suggestions

1

1 Answers

1
votes

You aren't comparing 0 to 0. You are comparing the memory address of count_a to count_b. You'll need to access the .Value property of the object to get the value. Note that you would need to cast the Value into a primitive type. For the comparison you're performing, .Value.ToString() would suffice