我正在使用以下表达式:
[TIMEPERIOD_ID]==1?"JANUARY":
[TIMEPERIOD_ID]==2?"FEBRUARY":
[TIMEPERIOD_ID]==3?"MARCH":
[TIMEPERIOD_ID]==4?"APRIL":
[TIMEPERIOD_ID]==5?"MAY":
[TIMEPERIOD_ID]==6?"JUNE":
[TIMEPERIOD_ID]==7?"JULY":
[TIMEPERIOD_ID]==8?"AUGUST":
[TIMEPERIOD_ID]==9?"SEPTEMBER":
[TIMEPERIOD_ID]==10?"OCTOBER":
[TIMEPERIOD_ID]==11?"NOVEMBER":
[TIMEPERIOD_ID]==12?"DECEMBER"
它会引发以下异常:
错误-数据类型“ DT_WSTR”和“ DT_I4”不兼容 二进制运算符“ ==”。操作数类型不能隐式转换 转换为兼容类型的操作。要执行此操作, 需要使用强制转换运算符显式强制转换一个或两个操作数。
有什么建议吗?
答案 0 :(得分:2)
从上述错误中可以看出,[TIMEPERIOD_ID]
数据类型为DT_WSTR
,无法将其与整数值进行比较。尝试以下表达式:
[TIMEPERIOD_ID] == "1" ? "JANUARY" :
[TIMEPERIOD_ID] == "2" ? "FEBRUARY" :
[TIMEPERIOD_ID] == "3" ? "MARCH" :
[TIMEPERIOD_ID] == "4" ? "APRIL" :
[TIMEPERIOD_ID] == "5" ? "MAY" :
[TIMEPERIOD_ID] == "6" ? "JUNE" :
[TIMEPERIOD_ID] == "7" ? "JULY" :
[TIMEPERIOD_ID] == "8" ? "AUGUST" :
[TIMEPERIOD_ID] == "9" ? "SEPTEMBER" :
[TIMEPERIOD_ID] == "10" ? "OCTOBER" :
[TIMEPERIOD_ID] == "11" ? "NOVEMBER" :
[TIMEPERIOD_ID] == "12" ? "DECEMBER" : ""