locked
Getting Random Records from Access Table RRS feed

  • Question

  • User850644279 posted

    Dear All, i am experience a strange issue here, i have a database for Questions for an online testing app.

    i have a table for tests.

    i am using the following code:

    SELECT Top 10 Question_Id, Question, right_answer, module_id, a, b, c, d FROM Tests ORDER BY Rnd(Question_Id) * NOW() ", mycon);

    OleDbCommandBuilder mycmd = new OleDbCommandBuilder(myadapter);

    DataSet myds = new DataSet();

    myadapter.Fill(myds);

    DataTable dt = new DataTable();

    myadapter.Fill(dt);

    foreach (DataRow dr in dt.Rows)

    {

    Label1.Text = "<br />" + dr["Question_ID"].ToString() + " ";

    }

    when i try the excution of this select stat. in access querys or in vs studio it works fine but when excuting the code in the page it gives the same values each time .

    SELECT Top 10 Question_Id, Question, right_answer, module_id, a, b, c, d FROM Tests ORDER BY Rnd(Question_Id) * NOW()

     

    i am confused as there is nothing wrong with the select as it displayes different values each time in access or in vs designer but on code noooo.

     note:

    i have tried other randomizing functions like newid() and uuid() and the same thing happenes

    can any body hep with with this

    thanks

     


     

    Friday, March 27, 2009 5:46 PM

Answers