I am not very confident with the capabilities of SqlDataReader
and how it works, would it be possible for me to create something that for each StudentID
found corresponding to the SQL query, it displays every ID in a different label? And if so could you please help me out in how I would achieve this.
This is my code that I have so far with the SQL query:
private void SetTestsForm_Load(object sender, EventArgs e)
{
string y = GlobalVariableClass.Signedinteacher;
string connectionString = ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString;
SqlConnection connect = new SqlConnection(connectionString);
connect.Open();
SqlCommand command20 = new SqlCommand(@"SELECT [StudentID] FROM StudentDetails WHERE ([TeacherID] = @signedinteacher)", connect);
command20.Parameters.AddWithValue("@signedinteacher", y);
SqlDataReader reader = command20.ExecuteReader();
}