在Vb.net中使用Order By排序

黑珍珠

尝试ORDER BY在vb.net中使用对记录进行排序,但没有得到所需的结果。我从两个不同的表中获取记录,但排序使用单个表中的一列。

代码

'query data
    Dim cmd As OleDbCommand = New OleDbCommand("SELECT biodata_info.student_id, sname, mname, fname, passport, " & _
                            " result_score FROM biodata_info LEFT JOIN [" & connResultLink & "].result_summary ON biodata_info.student_id = result_summary.student_id " & _
                            "WHERE result_term = @resultTerm  AND result_session = @resultSession AND result_class = @resultClass AND result_arm = @resultArm " & _
                            " ORDER BY result_summary.result_score ASC", connStudent)

    cmd.Parameters.AddWithValue("@resultTerm", term1)
    cmd.Parameters.AddWithValue("@resultSession", session1)
    cmd.Parameters.AddWithValue("@resultClass", className1)
    cmd.Parameters.AddWithValue("@resultArm", armName1)

使用ASC的结果

<1> 1011
<2> 863
<3> 911
<4> 985

使用DESC的结果

<1> 985
<2> 911
<3> 863
<4> 1011
佐哈尔·皮莱德(Zohar Peled)

在我看来,您的result_summary.result_score列不是数字数据类型,而是字符串数据类型。尝试CInt(result_summary.result_score)在order by子句中使用。

阅读此链接,了解ms-access(和其他Office产品)中的类型转换。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章