private void cbo_MaThuoc_SelectedIndexChanged(object sender, EventArgs e) { string strsel = "select GiaBan from Thuoc where TenThuoc LIKE N'%" + cbo_MaThuoc.Text.Trim() + "%'"; SqlDataReader dr = conn.excuteReader(strsel); while (dr.Read()) { txt_DonGia.Text = dr["GiaBan"].ToString(); } dr.Close(); conn.ClosedConnection(); }
public string getID(string user, string pass) { string id = ""; try { conn.OpenConnection(); string strSql = "SELECT * FROM NhanVien WHERE userName ='******' and password='******'"; SqlDataReader dr = conn.getReader(strSql); while (dr.Read()) { id = dr["TenNV"].ToString(); } } catch (Exception) { MessageBox.Show("That bai khi ket noi"); } finally { conn.ClosedConnection(); } return(id); }