예제 #1
0
        public Course Find(int id)
        {
            Course course = null;

            db.Open();

            string sql = "SELECT * FROM Courses WHERE Id=@Id";

            db.InitCommand(sql, CommandType.Text);
            db.AddInputParameter(DbType.Int32, "Id", id);
            SqlDataReader reader = db.ExecuteReader();

            if (reader.Read())
            {
                course = MapData(reader);
            }
            db.Close();
            return(course);
        }