Hey I am trying to do a project on Test Engine. I need to retrieve random rows of questions from access database. I did the following code, but every time I once close and run it again, the sequence of questions is same. How can I change the sequence every time?

private void button1_Click(object sender, EventArgs e)
        {
            OleDbConnection con = new OleDbConnection(Connection.conStr);
            OleDbCommand cmd = new OleDbCommand("select * from dell order by Rnd(serialNumber)", con);
            OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds, "new");
            dataGridView1.DataSource = ds.Tables["new"];
        }

Use any of these Queries

SELECT *, rand(@@IDLE % (@@ROWCOUNT + serialNumber))as xx FROM dell ORDER BY xx
//or
SELECT *,(sin(serialNumber * rand())) as xx from dell
ORDER BY xx

Edited 5 Years Ago by abelLazm: n/a

This question has already been answered. Start a new discussion instead.