Good day everyone,

so here, i have a problem with my repeater control's sql query, what i would really want to happen, is i have a randomized number from 1 to 60, that will tell the database which test question to select, (if it's only one, it's not a problem, haha.) but then, i am required to display 20 questions from my database to the repeater control. my database also holds the 60 questions. so yeah, i tried some solutions in the net, but then my code always returns only one record, and it's quite a pain. hope somebody could help me, i know to some it's quite basic, but i'm only a budding programmer, so yeah, thanks in advance.

btw, this is the chunk of code,

   protected void Page_Load(object sender, EventArgs e)
        int i = 1;
        Random r = new Random();
            while (i <= 20)
                int iss;
                string constr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mark\Desktop\thesis\WebSite8\App_Data\thesisDB.mdf;Integrated Security=True;User Instance=True";
                SqlConnection con = new SqlConnection(constr);
                string com = "SELECT * from CHAP1_quiz WHERE questionnumber = @num";
                SqlDataAdapter comms = new SqlDataAdapter();
                SqlCommand cmd = new SqlCommand(com, con);
                iss = r.Next(1, 60);
                comms.SelectCommand = cmd;
                DataSet ds = new DataSet();
                Repeater1.DataSource = ds;



SELECT TOP 20 * FROM from CHAP1_quiz ORDER BY newid()

This SQL statement will fetch 20 rows (random order by NEWID()) from the database.

Code block:

using(SqlConnection connection=new SqlConnection(constr))
 string sql="SELECT TOP 20 * FROM from CHAP1_quiz ORDER BY newid()";
 using(SqlDataAdpater adp=new SqlDataAdapter(sql,connection))
   DataTable dataTable=new DataTable();
   Repeater1.DataSource = dataTable;