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;
cmd.Parameters.Add("@num");
DataSet ds = new DataSet();
con.Open();
comms.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
i++;;
con.Close();
}
}`