How to use ternary operator inside the select syntax?

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


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

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.


Do you want to check DC column is null? or What is your expected output of select syntax?

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.


From where do you get row(“Project Code”).ToString?

what are you assigning it to basically ?