From db i am getting lot of phone number so how to save it

Hi i am getting some data in db from that i got all phone numbers using for each now what i need to do is i need to save all of them in one variable in this format ‘phn1’,‘phn2’…

how to do it

You can try below expression

String PhoneNumbers="'"+String.Join("','",InputDB.AsEnumerable().Select(Function(x) x("PnoneNumber").ToString()).ToList())+"'"

Hi @manoj_verma1

Try the below expression

String.join(",",DT.DefaultView.ToTable(true, "Phonenumber").AsEnumerable().Select(Function (a) a("Phone number").ToString).ToArray())

Hope it will work


@poorna_nayak07 @Gokul001 one more thing actually th db does not have haeders in it so i used row(0).tostring will tis work

Yes it will

1 Like

i am using assign inside for each and instead of phone number row(0).tostring

You don’t need to use for each activity.

Use only Assign activity @manoj_verma1


so instead of phone number what should i put in
row(0) — getting error does not belong

@Gokul001 @poorna_nayak07

Try to give only the Index ->0

String.join(",", GetfileDT.DefaultView.ToTable(true, “0”).AsEnumerable().Select(Function (a) a(“0”).ToString).ToArray())

same does not belong

Try this expression @manoj_verma1

String.join(",", GetfileDT.DefaultView.ToTable(true, 0).AsEnumerable().Select(Function (a) a(0).ToString).ToArray())

Hey @manoj_verma1 !! I’m going to create a test table just for us to visualize. First let’s convert the column with the phone numbers into an array and with that we get the expected Output. Come with me!!

dt_result.AsEnumerable().Select(Function (a) a(0).ToString).ToArray()

  • Step3: Let’s get your expected Output with String.Join() and store it in a variable of type String “str_result”

The result:

Hope it helps!

The .xaml.
Main.xaml (10.2 KB)

in step 1 header is not there like phn number i am getting the data through API

Are you talking about Column Name?

yes column name so i used row(0).to string to get one by one

No problem, we are getting the phone number by column index 0. The name makes no difference.

try using the logic I showed above, it will probably work for you!

1 Like

@gabrielribas4 it worked but i want to save it like this ‘123’,‘234’,‘456’,…

Ok! Just change this Assign Activity!


1 Like

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