public Types.CargosType select() { SqlConnection con = new SqlConnection(Dados.StringConexao); string SQL = "SELECT * FROM CARGO"; SqlCommand cmd = new SqlCommand(SQL, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Types.CargosType types = new Types.CargosType(); while (dr.Read()) { Types.CargoType type = new Types.CargoType(); type.IdCargo = Int32.Parse(dr["ID_CARGO"].ToString()); type.IdDepartamento = Int32.Parse(dr["ID_DEPARTAMENTO"].ToString()); type.Descricao = dr["DESCRICAO"].ToString(); types.Add(type); } return types; }
public Types.CargosType select() { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "SELECT * FROM CARGO"; MySqlCommand cmd = new MySqlCommand(SQL, con); con.Open(); MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Types.CargosType types = new Types.CargosType(); while (dr.Read()) { Types.CargoType type = new Types.CargoType(); type.IdCargo = Int32.Parse(dr["ID_CARGO"].ToString()); type.IdDepartamento = Int32.Parse(dr["ID_DEPARTAMENTO"].ToString()); type.Descricao = dr["DESCRICAO"].ToString(); types.Add(type); } return(types); }