Esempio n. 1
0
        public List <students> getAll(int id)
        {
            students        rec;
            List <students> list = new List <students>();

            strQuery = "select stu_id,stu_name from Student where stu_id in (select stu_id from teaches where fac_id=" + id + ");";
            SqlDataReader dr;

            try
            {
                conobj.openconnect();
                cmd = conobj.execute(this.strQuery);
                dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    rec = new students();

                    rec.ID   = dr.GetInt32(0);
                    rec.Name = dr.GetString(1);
                    list.Add(rec);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            finally
            {
                conobj.closeconnect();
            }
            return(list);
        }