Remove rows based on another datatable

i have 2 datatable .Dt1 and dt2.

Both have same columns- conversationID and Reminder count

I need to remove rows in dt2 that have same rows as dt1 .Do we have any activity for it

Both the columns values should match ,only then we need to remove that row

1 Like

@tharani.natarajan

For Each Row (row1) in dt1
For Each Row (row2) in dt2
If (row1(“conversationID”).ToString = row2(“conversationID”).ToString) AndAlso (row1(“Reminder count”).ToString = row2(“Reminder count”).ToString)
Remove Data Row: row2
End If
End For Each
End For Each

or

Join Data Tables:

  • Left Table: dt2
  • Right Table: dt1
  • Join Type: Inner Join
  • Join Columns: conversationID, Reminder count
  • Result: joinedResult

Filter Data Table:

  • Input: joinedResult
  • Condition: conversationID = “”
  • Output: filteredResult

Assign: dt2 = filteredResult

1 Like

Hey @tharani.natarajan ,

You can try this query,

dt2.AsEnumerable.Except(dt1.AsEnumerable, System.Data.DataRowComparer.Default).CopyToDataTable
1 Like

Hi @tharani.natarajan

Simply use the below linq expression to delete the common row in datatable1 and datatable2

=> Assign -> dt2 = dt2.AsEnumerable().Except(dt1.AsEnumerable(), DataRowComparer.Default).CopyToDataTable()

Hope it helps!!

1 Like

Hi @tharani.natarajan

you can use this its working

=> Assign → dt2 = dt2.AsEnumerable().Except(dt1.AsEnumerable(), DataRowComparer.Default).CopyToDataTable()

1 Like

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