返回首页

我试图找到一排列值的数据集。列是一个boolean类型的数据。

 Dim foundRows() As Data.DataRow

foundRows = dsans.Tables(0).Select("correct_ans = 'true'")

               Dim j As Integer

               Dim iRowIndex As Integer

               For j = 0 To dtans.Rows.Count - 1

                   If dtans.Rows(j).Equals(foundRows) Then

                       iRowIndex = j

                       Exit For

                   End If

               Next

               answer = dtans.Rows(iRowIndex).Item(1)

每次,它返回第一row.It的未检查的条件
correct_ans ='真'。在select语句是什么错误?

回答

评论会员:游客 时间:2012/02/04
Prera​​k帕特尔
如果是布尔值,只是尝试
{C}你比较的是字符串类型,而不是为布尔
[编辑]
我真的错过了这一部分,当我第一次发现的问题。

For j = 0 To dtans.Rows.Count - 1

  If dtans.Rows(j).Equals(foundRows) Then

    iRowIndex = j

    Exit For

  End If

Next
foundRows是DataRow数组。你正在尝试的是等同的DataRow
评论会员:游客 时间:2012/02/04
是什么类型的correct_ans领域。这是布尔或字符串?你在这里做的比较实质上是一个字符串,所以没有返回结果,如果类型不匹配