I am developing an online examination system, but im having difficulties trying to read questions from the database to be displayed on an aspx on page load. Please help me out...wat do i do...i tried this code but its not working well.
string cs = ConfigurationManager.ConnectionStrings["OnlineExamDBCS"].ToString();
SqlConnection conn = new SqlConnection(cs);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT questionTitle, Answer1, Answer2, Answer3, Answer4, Answer5
FROM tblQuestions WHERE CourseCode = \'" + question + "\'";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
LabelRadio1.Questions = reader["questionTitle"].ToString();
LabelRadio1.Answers = reader["Answer1"].ToString();
LabelRadio1.Answers = reader["Answer2"].ToString();
LabelRadio1.Answers = reader["Answer3"].ToString();
LabelRadio1.Answers = reader["Answer4"].ToString();
LabelRadio1.Answers = reader["Answer5"].ToString();
}