一考试系统,需要随机在题库里面抽题。小弟用的Access数据库题全放在Question表里 Question里有ID列  1-900 对应900道题目。之前用了 
string s=select top 100 question,strA,strB,strC,strD,Pic,strR ,Code from question where ID between 1 and 900 order by rnd(id)insert into Exam (question,strA,strB,strC,strD,Pic,strR,Code) " + s + " 以上方法。随机抽出题目了,但下次运行时 还是抽出和前一次随机抽出的一样的100道题。。 很郁闷。。不知道什么原因。各位有没有什么好的方法可以实现此功能?!在Question中随机抽100题,然后把这100道题插入到Exam表中
(要确保每次运行抽出的100道题目,插入到Exam中后都不同) 这才是关键!!!!!强人们,吃完饭过来看看吧。

解决方案 »

  1.   

    这个问题的提问频次很高啊,遇到第三次了【转】用C#生成不重复的随机数 http://www.cnblogs.com/aooyu/archive/2009/11/09/1599257.html
      

  2.   

    newid()   是   sql   server   的函数
     rnd 函数可以有类似的功能,但是这个的缺点是每次用之前要randomize,否则每次的次序是一样的
      

  3.   


    order by newid(),产生随机id序列
    newId只能在sqlserver里用
      

  4.   

    http://www.cnblogs.com/aooyu/archive/2009/11/09/1599257.html
      

  5.   


    select top 100 question,strA,strB,strC,strD,Pic,strR ,Code from question where ID between 1 and 900 order by newid()
      

  6.   

    请问 randomize  怎么弄?
      

  7.   

    newid 在ACCESS 下能用。。?  提示未定义。
      

  8.   

    楼主用order by rnd(id),id列必须为 “自动编号” 字段
      

  9.   


    randomize是VB语句,楼主用的是VB?
      

  10.   

    我用C#。做的winform。请教了。
      

  11.   

    //采用时间作为种子
    Random ra=new Random(unchecked((int)DateTime.Now.Ticks));
      

  12.   


    sql语句,加个时间做种子
    order by rnd(-1   *   ID   +   time()) 
      

  13.   

    大哥你懂top 100 是什么意思么?
    你top 100肯定每次取出的值都是一样的
    建议你将所有的题都取出来,在C#代码里随机抽取试题
      

  14.   

    select top 100 item_no from t_bd_item_info where item_no between 100001 and 100900 order by newid()
    这个说的好