How to delete datarow in datatable?

hi

*Having two data tables(same column name)
*used if condition for row matching(if the row value is same in both tables then need to delete that record)

Till if condition have completed.But I’ve used remove data row activity for delete that true matching row.

forgot to use that remove data row…may i know how to use this scenario?..using that how can i delete the record?..

1 Like

Hi @ganesh_rajan

Use condition

row(“Column Name”).ToString.Contains(row(“Column Name”).ToString

use remove data row activity in then condition

Thanks
Ashwin S

I forgot how to use remove data row?..will you tell those details

image

hi @ganesh_rajan

mention that in row property

Thanks
Ashwin S

what i need to put?

hi @ganesh_rajan
mention the row of the column of the datatable

can you send a some sample?

Hi @ganesh_rajan
Check this

Thanks
Ashwin S

it’s throwing this error

image

is this correct?

No worries
Hope these steps would help you resolve this
—Inside the IF activity If the condition gets true it will go to THEN apart I hope
—So inside the THEN part use a ADD TO COLLECTIONS activity
—Where in that activity property panel along the collections property mention as list_rowindex where list_rowindex is a variable of type System.collections.generic.list(of int32) with default value New List(of integer) defined in the variable panel and in the item property mention as yourdatatablename.Rows.Indexof(row) where row is a variable used in your for each row loop
—so the row index will get added to this list variable

—now next to this for each row loop use a For each activity and pass the input as list_rowindex and change the type argument as int32 in the property panel of for each loop activity
And inside the loop use REMOVE DATAROW activity and mention the rowindex as item and mention the datatable name in the datatable property
Use another REMOVE DATAROW ACTIVITY and mention the rowindex as item and mention another datatable name in the datatable property so that now the row will get deleted in both the datatable

Hope this would help you
Cheers @ganesh_rajan

i don’t want delete both tables…now my aim is delete in row2 loop only…row1 loop data for just comparison purpose only

1 Like

Fantastic
Then we can keep one REMOVE DATAROW ACTIVITY alone and mention the datatable from which we need the row
And remaining process is same and last step within the for each loop will alone change
Cheers @ganesh_rajan

is this right way?

1 Like

Yah the expression is fine but we cannot use REMOVE DATAROW ACTIVITY inside thr for each row loop as we are currently iterating through each row in the datatable and meanwhile we won’t bale to delete the rows in it and that why Ymir’s was showing that error.
So we need to get the row index now using add to collections activity and use a separate for each loop activity and pass the variable used in the add to collections- as input here in for each loop activity and then use remove datarow activity inside the loop
Same as these steps

Cheers @ganesh_rajan

3 Likes

is it working buddy
do we have any queries to be discussed
Cheers @ganesh_rajan

Do you have any sample buddy?

1 Like

here you go
sample xaml
example.zip (16.9 KB)

Cheers @ganesh_rajan

2 Likes

thanks buddy…i will check it

1 Like

Great
Cheers @ganesh_rajan

1 Like