예제 #1
0
        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);
        }
예제 #2
0
        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);
        }