如何随机从数据库中检索数据 [英] How to retrieve data from database randomly

查看:96
本文介绍了如何随机从数据库中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的喜!我是vb.net编程的新手。我正在制作这个简单的测试应用程序,我想知道如何从数据库中随机检索数据。这是我的sql server数据库表imgage。 http://www.photoshop.com/users/akosibogart/albums/1770ea40419f4176a14c0f055807270e/view#e9c1e825e5394da5afef1c5699f848fb [ ^ ]



VB表格: http:// www.photoshop.com/users/akosibogart/albums/1770ea40419f4176a14c0f055807270e/view#c5fad573b3c04b85bb3858ab122be112 [ ^ ]





问题和疑问:用户将点击生成问题按钮retri从表调查表中随机抽取数据。接下来,用户将从文本框中键入正确的答案在此处键入您的答案然后检查按钮将检查AnswerTextbox是否等于textbox1,这是您在此处输入答案的文本框。我在这种编码方法中使用数据绑定。你可以帮助我。在这种编程语言的im noob。我怎么能这样做?

hi! i am new in vb.net programming.i am making this simple test application and i would like to know how can i retrieve data from database randomly.this is my sql server database table imgage. http://www.photoshop.com/users/akosibogart/albums/1770ea40419f4176a14c0f055807270e/view#e9c1e825e5394da5afef1c5699f848fb[^]

VB form: http://www.photoshop.com/users/akosibogart/albums/1770ea40419f4176a14c0f055807270e/view#c5fad573b3c04b85bb3858ab122be112[^]


Problem and Question: The user will click generate question button to retrieve a data randomly from the table questionnaire.Next, the user will type the correct answer from the textbox "Type your answer here" then check button will check if AnswerTextbox is equal to textbox1 which is the input your answer here textbox. Im using databinding in this coding method.hope u can help me. im noob in this programming language.any idea on how can i do this?

推荐答案

如果你的ID值是连续的,你知道最大值和最小值,最简单方法是检索这两个值之间具有随机ID的重新编码。 SQL没有随机行的概念,因此在表示层中执行此操作要容易得多。同时,您可以记录您已经询问过特定用户的哪些问题,以便您不再问它...
Provided your ID values are contiguous and you know teh max and min values, the easiest way is you to retrieve a recode with a random ID between those two values. SQL doesn''t have an concept of "a random row" so it is a lot easier to do that in your presentation layer. At the same time, you can keep a record of which questions you have already asked a particular user, so that you don''t ask it again...


请检查以下链接。

http://www.sqlteam.com/article/ using-newid-to-random-sort-records [ ^ ]



当用户首次访问系统时,您必须为他设置随机化问题列表(您可以使用表(userid,questionid))。然后,您可以从该表中检索问题1并显示给用户。
Please check following link.
http://www.sqlteam.com/article/using-newid-to-randomly-sort-records[^]

When the user first accessing to the system, you have to setup the randomize question list for him (you can use the table (userid, questionid)) for that. Then you can retrieve question 1 by 1 from that table and display to the user.


tNx专家现在我知道..我的测试表现在正在运行。
tNx experts now i know.. my test form is now working.


这篇关于如何随机从数据库中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆