public static List <SexoItemVM> obtenerListaSexos() { List <SexoItemVM> resultado = new List <SexoItemVM>(); string cadenaConeccion = System.Configuration.ConfigurationManager.AppSettings["CadenaConexion"]; OleDbConnection conexion = new OleDbConnection(cadenaConeccion); try { OleDbCommand comando = new OleDbCommand(); string consulta = "SELECT * FROM Sexo"; comando.Parameters.Clear(); comando.CommandType = System.Data.CommandType.Text; comando.CommandText = consulta; conexion.Open(); comando.Connection = conexion; OleDbDataReader dr = comando.ExecuteReader(); if (dr != null) { while (dr.Read()) { SexoItemVM aux = new SexoItemVM(); aux.IdSexo = int.Parse(dr["id"].ToString()); aux.Nombre = dr["nombre"].ToString(); resultado.Add(aux); } } } catch (Exception) { throw; } finally { conexion.Close(); } return(resultado); }