Example #1
0
        public ArrayList readAllCoreHomework()
        {
            ArrayList allCoreHomework = new ArrayList();
            string    query           = "SELECT * from CoreHomework";

            conn.Open();
            SqlCommand    cmd = new SqlCommand(query, conn);
            SqlDataReader re  = cmd.ExecuteReader();

            while (re.Read())
            {
                Homework hw = new Homework(re["CoreHomeworkID"].ToString(), re["LastEditBy"].ToString(), re["MinutesToComplete"].ToString(), re["HomeworkTitle"].ToString());
                allCoreHomework.Add(hw);
            }

            conn.Close();
            return(allCoreHomework);
        }
Example #2
0
        public Homework readSingleCoreHomework(string id)
        {
            string   query = "SELECT * from CoreHomework where CoreHomeworkID = '" + id + "'";
            Homework selectedCoreHomework = new Homework();

            conn.Open();

            SqlCommand cmd = new SqlCommand(query, conn);
            //cmd.Parameters.AddWithValue("@id", id);
            SqlDataReader re = cmd.ExecuteReader();

            while (re.Read())
            {
                selectedCoreHomework = new Homework(re["CoreHomeworkID"].ToString(), re["LastEditBy"].ToString(), re["MinutesToComplete"].ToString(), re["HomeworkTitle"].ToString());
            }

            conn.Close();
            return(selectedCoreHomework);
        }