Hello team, i need to add data to datable using add data column and put data in Database. pls provide the solution.Tq

This is my scenario.
1.I am iterating data(Name) using ForEach Activity.
2.Now i need to add data(Name) to DataTable to specific column.
3. Same scenario for remaining data also(Mobile, category, ID etc)
4. Once all column data added to Datatable I need to put in DataBase and clear the DataTable.

Pls provide the solution.Tq very much

Hi @Lokesh_M2,

Can you tell us what is your input? From where are you getting Name, Mobile and other data?

Hi, iam getting data from matches activity and iterating using For each

Okay. Then you can use add datarow activity in same loop to add to datatable.

image

Add your data in place of name, mobile etc.

Later use Bulk insert activity to upload the datatable into database.

But my scenario is iam iterating each data using individual Foreach

Please post some sample raw data so as to get exact scenario

are you setting row data in each iteration or single column data (if so the reason for setting a single column data )

Regards

Okay. If it is possible try to do in one for each, it would be more efficient.

Based on your current scenario, Use Build data table activity with all required columns.
Inside the first for each i.e Name, use add datarow to add only Name data.
Inside other for each, use assign activity.

outputDt(“Mobile”)(i) = mobileNo

where i is index of the for each.

Hope this helps.

Hi, iam setting In each iteration single column data

image
This my sample scenario

can you please refer to the below post you can get better understanding

https://forum.uipath.com/t/hi-team-pls-provide-regular-expression-for-the-data-tq/531373/8

Regards

@Lokesh_M2

On change that you can do is…use 4 matches activity at first…and store them
To 4 variables…and I hope all will return same number of values…

So you can use one for loop on one of the matchcollection variables…and for loop properties has a property called index…to which we can add a variable and use it to iterate through remaining match collections

So in add datarow you can use like this

Eg: {currentitem.Value,match2(indexvalue).value, match3(indexvalue).value, match4(indexvalue).value}

Then in one loop you call add all at a time

Here each match is the output of each matches activity

Hope this helps

Cheers

Try this sample workflow.

Provided all data counts are same.

1 Like

Hi @Harshith_Adyanthaya, what is the type argument for ForEach used?
it is showing error if i am using using system.text.regularxpression.match

System.Text.RegularExpressions.Match

What is the error?

@Lokesh_M2

Strhotelname looks like a string variable and not matches variable …can you scheck the same please

Basically as explained above the concept is to loop theough each matched item for different matches

Hope this helps

Cheers

yes now i used matches variable.Now while running error thrown like this
image

@Lokesh_M2

Can you show how you are using…looks like its different again

Alternately try this match1.ToArray) (0).Value

Cheers

image

@Lokesh_M2

I see you are using strnachotel…can you check the variable type please

Cheers