opas1216
(Michael Hsieh)
August 29, 2019, 11:08am
1
Here’s my sample:
TestDT.Select(“[Project Code]= '” + row(“Project Code”).ToString + If(row(“DC”).ToString.Equals(“”) , “'”, “‘AND [DC]=’” + row(“DC”).ToString + “'”))
And it showed “Value of type 1-dimensional array of System.Data.DataRow cannot be converted to Boolean”
Is there any syntax issue or the ternary operator cannot be used like this?
Thanks in advance
aanandsanraj
(Anandraj Rajendran)
August 29, 2019, 11:35am
2
@opas1216
What are you trying to do in that code?
Actually the code ternary operator returning a boolean value that is why you are getting the error
opas1216
(Michael Hsieh)
August 29, 2019, 2:38pm
3
@aanandsanraj
Thanks for your answer.
I want to make the condition which inside the select syntax can be dynamically recognized whether it has content or empty.
As my sample, the condition of “DC” might contains some info most of times, but it has some exceptions that “DC” might be no content inside.
Hence that’s the reason why I tried to use ternary operator, otherwise it can’t get results when “DC” be empty which cause get the wrong report.
@opas1216
Do you want to check DC column is null? or What is your expected output of select syntax?
opas1216
(Michael Hsieh)
August 30, 2019, 7:33am
5
I want to make sure whether DC is null
If DC is not null, then I can use select([Project Code] = XXXX, [DC] = YYYY)
Otherwise, I would only use select([Project Code] = XXXX)
If I include the DC as condition when DC is null, the data will not be correct result.
That’s why I want to do this.
@opas1216
From where do you get row(“Project Code”).ToString ?
what are you assigning it to basically ?