public List <Ativo> selectAtivo(int idAtivo) { List <Ativo> lista = new List <Ativo>(); Ativo ativo = new Ativo(); //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; CnxSql cnxSql = new CnxSql(); using (cnxSql.cnx) { cnxSql.cnx.Open(); String select = "select p.IDATIVO from possui as p Where p.IDUSER = @id order by p.IDATIVO desc"; using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx)) { cmd.Parameters.AddWithValue("@id", idAtivo); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { lista.Add(new Ativo() { id = reader.GetString(0) }); //ativo.nome = reader.GetString(1); //lista.Add(ativo); } } } return(lista); } }
public List <Usuario> selectUsuario() { List <Usuario> lista = new List <Usuario>(); Ativo ativo = new Ativo(); //String connection = "Server=tcp:lol-2018.database.windows.net,1433;Initial Catalog=ADS 2018;Persist Security Info=False;User ID=jessicasantos;Password=Corinthians11;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; CnxSql cnxSql = new CnxSql(); using (cnxSql.cnx) { cnxSql.cnx.Open(); String select = "select * from Usuario"; using (SqlCommand cmd = new SqlCommand(select, cnxSql.cnx)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { lista.Add(new Usuario() { idUser = int.Parse(reader["IDUSER"].ToString()), nome = reader["nome"].ToString(), telefone = reader["telefone"].ToString(), isAdm = bool.Parse(reader["isADM"].ToString()) }); //ativo.nome = reader.GetString(1); //lista.Add(ativo); } } } return(lista); } }