2016-09-26 29 views
2

我想比較兩個數據行row和row1中的值。但是,此代碼生成錯誤比較數據行中的值VB

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 

錯誤:代替

Value of type 'System.Data.DataRow' cannot be converted to 'Boolean'

回答

2

使用圓括號()[]

這會工作:

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