Error in Invoke code Linq query: "rowSheet2 cannot be used in lambda expression"

So I am using a linq query to update column values that match after comparing 2 columns, but it is giving error : “rowSheet2 cannot be used in lambda expression” Below is the query I am using. Can someone please help resolving it?

For Each rowSheet2 In dt2.Rows
Dim matchingRows = dt1.AsEnumerable().Where(Function(row) row(“REPORTING_PAYROLL”).ToString = rowSheet2(“MasterTax”).ToString).ToList()

If matchingRows.Count > 0 Then
’ Match found, update values in dtSheet1
matchingRows(0)(“Company: Short Name”) = rowSheet2(“Company: Short Name”)
matchingRows(0)(“Company: Name”) = rowSheet2(“Company: Name”)
Else
’ No match found, add a new row to dtSheet3
dt3.Rows.Add(rowSheet2.ItemArray)
End If
Next

You can fix by:

grafik

Dim rowSheet2 As DataRow
For Each rowSheet2 In dt2.Rows
Dim matchingRows As List(of DataRow) = dt1.AsEnumerable().Where(Function(row) row("REPORTING_PAYROLL").ToString = rowSheet2("MasterTax").ToString).ToList()

If matchingRows.Count > 0 Then
’ Match found, update values In dtSheet1
matchingRows(0)("Company: Short Name") = rowSheet2("Company: Short Name")
matchingRows(0)("Company: Name") = rowSheet2("Company: Name")
Else
’ No match found, add a New row To dtSheet3
dt3.Rows.Add(rowSheet2.ItemArray)
End If
Next

Ensure that all doublequotes are of type: " and not inverted