Get Value from Data table: Missing operand after 'string' operator

Hi there

I am trying to assign a value from a data table to a string variable using dt.select
I have tried these solutions:

StringVar = DataTable.Select(“[LookUpColumnName] = '” + AnotherStringVar + “'”)(0).Item(4).ToString

And

StringVar = DataTable.Select(“[LookUpColumnName] = '” + AnotherStringVar + “'”).Single().Item(“TargetColumn”).ToString

No errors in assign activity but when running it I get:
Missing operand after ‘string’ operator

What is the correct syntax ?

HI @Hawkman

Try this in string variable

Datatable.Rows.Item(4)(AnotherStringVar)

Regards
Sudharsan

Hi @Hawkman ,

Maybe you could also check with the below Expression :

DataTable.Select("[LookUpColumnName]='"+ AnotherStringVar.Trim + "'")(0).Item(4).ToString

or

DataTable.AsEnumerable.Where(Function(x)x("LookUpColumnName").ToString.Equals(AnotherStringVar.Trim)).First.Item(4).ToString

Let us know if you are still facing issues with both the Expressions and maybe let us know what were the error messages for each one.

Hello @Hawkman

The below expression seems to be valid.

DataTable.Select(“[LookUpColumnName] = ‘” + AnotherStringVar + “’”)(0).Item(4).ToString

Can you print the below message box and share the screenshot here.

“[LookUpColumnName] = ‘” + AnotherStringVar + “’”

Thanks

Yes, I am sorry, it was my mistake.

This solution works now, since my var (row.item(“Bilagsnummer”).ToString) is already containing an apostrophe (') before the value:

reportDT.Select(“[Bilagsnummer] = “+row.Item(“Bilagsnummer”).ToString+”'”).Single().Item(“Beløp NOK”).ToString

Good to hear that @Hawkman

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.