NITHIN SUHAS NITHIN SUHAS - 2 months ago 28
Vb.net Question

comparing values in a datarow VB

I want to compare Values in two datarows row and row1. but this code is Generating an Error

For Each row As DataRow In dt.Rows

For Each row1 As DataRow In tmpdt.Rows
If row["STATE"].Tostring() = row1["STATE"].Tostring()


End If
Next

Next


Error are
value of 'System.data.datarow' cannot be converted to 'Boolean' and
Expression expected.

Answer

Use round brackets () instead of []

This would work:

For Each row As DataRow In dt.Rows
    For Each row1 As DataRow In tmpdt.Rows
        If row("STATE").Tostring() = row1("STATE").Tostring() Then

        End If
    Next
Next