>>Hi everybody,
>>
>>I am not sure why I am getting the error 'can not implicitly convert string booking type to Boolean') when I try to apply C# iif as in this command
>>
>>
>>sqlCommand.CommandText = "SELECT * FROM dbo.b_sched WHERE " + columnName +
>> @" = @columnValue and start_time IS NOT NULL
>> AND layer < 7 and is_pod" + ("POD"== bookingType)?">0":"=0";
>>
>>bookingType defined as String.
>>
>>Do you see what is wrong in this expression and why C# doesn't like it?
>
>
>Should it be something like bookingType.equals("POD")?
No, I think the problem is in the concatenation of first part and the result of C# iif. I am guessing C# can not deduce the type of the IIF expression.
The following works fine when I split the above into 2 expressions:
String podText = ("POD" == bookingType) ? ">0" : "=0";
sqlCommand.CommandText = "SELECT * FROM dbo.b_sched WHERE " + columnName +
@" = @columnValue and start_time IS NOT NULL
AND layer < 7 and is_pod" + podText;
If it's not broken, fix it until it is.
My Blog