public ArrayList readClassNames() { ArrayList allClassNames = new ArrayList(); string query = "SELECT ClassName from Class"; conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader re = cmd.ExecuteReader(); while (re.Read()) { SchoolClass cls = new SchoolClass(re["ClassName"].ToString()); allClassNames.Add(cls); } conn.Close(); return(allClassNames); }
public SchoolClass readSingleSchoolClass(string id) { string query = "SELECT * from Class where ClassID = @id"; SchoolClass selectedSchoolClass = new SchoolClass(); conn.Open(); SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@id", id); SqlDataReader re = cmd.ExecuteReader(); while (re.Read()) { selectedSchoolClass = new SchoolClass(re["ClassID"].ToString(), re["ClassTeacherID"].ToString(), re["ClassSubject"].ToString(), re["ClassYearGroup"].ToString(), re["ClassName"].ToString()); } conn.Close(); return(selectedSchoolClass); }