>>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?
>
>
>I think you need a space between
and is_pod[SPACE HERE?]" + ("[OR SPACE HERE?]POD"==I added space in the code although it didn't matter. The string expanded should be
and is_pod = 0 (when bookingType =="PVT")
and is_pod>0 (when bookingType =="POD")
So, I have my method working and tested already, I just found it a bit odd that C# compiler chocked on the way I tried to concatenate string and C# iff returning also string.
If it's not broken, fix it until it is.
My Blog