01/10/2018, 12:09
Code em return một đối tượng là sao vậy?
public List<ThongTinHS> findDSHSwithLop(int malop)
{
getConnection();
con.Open();
string sql = "select * from thongtinHS where malop=@malop";
SqlCommand cmd = new SqlCommand(sql,con);
cmd.Parameters.AddWithValue("malop", malop);
SqlDataReader rd = cmd.ExecuteReader();
List<ThongTinHS> dshs = new List<ThongTinHS>();
if (rd.Read())
{
ThongTinHS hs = new ThongTinHS();
hs.tenhs = Convert.ToString(rd["tenhs"]);
dshs.Add(hs);
}
con.Close();
return dshs;
}
Bài liên quan
↓
cảm ơn nhiều ạ!!! em ms học nên làm theo cách kia.