Add data rows using list

Hello everyone,
I got a problem, which is cant assign following
DT_bal = (from x in list_dict_bal select DT_bal.Rows.Add(x.Value[0],x.Value[1],x.Value[2],x.Value[3],x.Value[4],x.Value[5].Replace(“.0000”,“”),x.Value[6].Replace(“.0000”,“”),for_Code_bal,for_Msg_bal)).ToArray().CopyToDataTable()
List_dict_bal 's type is dictionary<string.list>
And the error says
BC30203 Identifier expected.
BC32017 Comma, ‘)’ , or a valid expression contunuation expected.
Can someone solve this please?
Regards,
Temuulen

Hi @Temuulen_Buyangerel

I Hope you are using VB Linq query, if yes, try the below syntax

DT_bal = (From x In list_dict_bal Select DT_bal.Rows.Add(x.Value(0), x.Value(1), x.Value(2), x.Value(3), x.Value(4), x.Value(5).Replace(".0000", ""), x.Value(6).Replace(".0000", ""), for_Code_bal, for_Msg_bal)).ToArray().CopyToDataTable()

Hope it helps!!

Hey, @Parvathy
Thanks for the quick reply.
There are still same errors.

Hi @Temuulen_Buyangerel

Are you using C sharp or VB code?

Regards

VB note but I copied it from the C#,
I see should I convert it to VB?

Regards

Hi @Temuulen_Buyangerel

Try this once:

DT_bal = (From x In list_dict_bal Select DT_bal.Rows.Add(x.Value(0), x.Value(1), x.Value(2), x.Value(3), x.Value(4), x.Value(5).Replace(".0000", ""), x.Value(6).Replace(".0000", ""), for_Code_bal, for_Msg_bal)).ToArray().CopyToDataTable()

Regards

1 Like

I got it, should use () instead of in vb right?
some errors are disappeared but it says
‘list_dict_bal’ is not declared. It may be inaccessible due to its protection level.
list_dict_bal is output of invoke code activity

should I assign it to other new variable?

Hi @Temuulen_Buyangerel

yes, In VB you need to use () instead of []. In C sharp we use []. In Invoke Code have you mapped the output variable correctly. what variable have you created there. If possible share some screenshots so that I can help you.

Regards

It was just a miss of writing it works fine.
Thanks for the solution!

1 Like

You’re welcome @Temuulen_Buyangerel

Happy Automation

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