【发布时间】:2011-03-22 17:01:53
【问题描述】:
我尝试在 Access 中随机订购带有查询的结果集。
我使用以下代码:
DIM TentamenQuestionID, TentamenQuestionResult, TentamenQuestionQuery, arrTentamenQuestion, arrTentamenQuestionIndex
Set TentamenQuestionResult = Server.CreateObject("ADODB.Recordset")
TentamenQuestionQuery = "SELECT TentamenQuestion.TentamenQuestionID, TentamenQuestion.TentamenQuestion, TentamenQuestion.TentamenQuestionSort " &_
"FROM TentamenQuestion " &_
"WHERE TentamenQuestion.TentamenID=" & TentamenID & " " &_
"ORDER BY Rnd(TentamenQuestion.TentamenQuestionID)"
TentamenQuestionResult.Open TentamenQuestionQuery, Connect, adOpenStatic, adLockReadOnly, adCmdText
If NOT TentamenQuestionResult.EOF then
arrTentamenQuestion = TentamenQuestionResult.GetRows()
End If
TentamenQuestionResult.Close
Set TentamenQuestionResult = Nothing
response.write(arrTentamenQuestion(0,0)) & "<br />"
response.write(arrTentamenQuestion(1,0)) & "<br />"
response.write(arrTentamenQuestion(2,0)) & "<br />"
response.write(arrTentamenQuestion(0,1)) & "<br />"
response.write(arrTentamenQuestion(1,1)) & "<br />"
response.write(arrTentamenQuestion(2,1)) & "<br />"
当我在 Access 中运行查询时,记录是随机选择的,但是当我使用此代码并响应时写入数组。该数组每次排序都相同,而不是随机排序。如何随机获取结果数组?
【问题讨论】: