2016-09-26 65 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