internal List <MercadoDTO> RetrieveByPartido(int id) { MySqlConnection con = Connect(); MySqlCommand command = con.CreateCommand(); command.CommandText = "SELECT tipo, cOver, cUnder FROM mercado WHERE partido = " + id; try { con.Open(); MySqlDataReader res = command.ExecuteReader(); MercadoDTO m = null; List <MercadoDTO> mercados = new List <MercadoDTO>(); while (res.Read()) { Debug.WriteLine("Recuperado: " + res.GetInt32(0) + " " + res.GetInt32(1) + " " + res.GetInt32(2) + " " + res.GetInt32(3) + " " + res.GetDouble(4)); m = new MercadoDTO(res.GetInt32(2), res.GetInt32(3), res.GetDouble(4)); mercados.Add(m); } con.Close(); return(mercados); } catch (MySqlException e) { Debug.WriteLine("Error al conectar con la base de datos"); return(null); } }
internal List <MercadoDTO> RetrieveDTO() { MySqlConnection con = Connect(); MySqlCommand command = con.CreateCommand(); command.CommandText = "select tipoMercado,cuotaOver,cuotaUnder from mercados"; try { con.Open(); MySqlDataReader resultado = command.ExecuteReader(); MercadoDTO mercado = null; List <MercadoDTO> mercados = new List <MercadoDTO>(); while (resultado.Read()) { Debug.WriteLine("Recuperado: " + resultado.GetDouble(0) + " " + resultado.GetDouble(1) + " " + resultado.GetDouble(2)); mercado = new MercadoDTO(resultado.GetDouble(0), resultado.GetDouble(1), resultado.GetDouble(2) ); mercados.Add(mercado); } con.Close(); return(mercados); } catch (Exception) { Debug.WriteLine("Ha ocurrido un error."); return(null); } }
internal List <MercadoDTO> RetrieveDTO() { MySqlConnection con = Connect(); MySqlCommand command = con.CreateCommand(); command.CommandText = "select * from mercado"; try { con.Open(); MySqlDataReader res = command.ExecuteReader(); MercadoDTO a = null; List <MercadoDTO> lista = new List <MercadoDTO>(); while (res.Read()) { Debug.WriteLine("Recuperado: " + res.GetDouble(1) + " " + res.GetDouble(2) + " " + res.GetDouble(3) + " " + res.GetDouble(4) + " " + res.GetDouble(5)); a = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3), res.GetDouble(4), res.GetDouble(5)); lista.Add(a); } return(lista); } catch (MySqlException e) { Debug.WriteLine("Se ha producido un error de conexion"); return(null); } }
internal MercadoDTO Retrieve() { MySqlConnection con = Connect(); MySqlCommand command = con.CreateCommand(); command.CommandText = "SELECT * FROM Mercado"; con.Open(); MySqlDataReader res = command.ExecuteReader(); MercadoDTO m = null; if (res.Read()) { Debug.WriteLine("Recuparado: " + res.GetDouble(1) + res.GetDouble(2) + res.GetDouble(3)); m = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3)); } return(m); }
internal List <MercadoDTO> RetrieveDTO() { MySqlConnection con = Connect(); MySqlCommand command = con.CreateCommand(); command.CommandText = "select * from mercados"; con.Open(); MySqlDataReader res = command.ExecuteReader(); MercadoDTO m = null; List <MercadoDTO> mercados = new List <MercadoDTO>(); while (res.Read()) { Debug.WriteLine("Recuperado: " + res.GetInt32(0) + " " + res.GetDouble(1) + " " + res.GetDouble(2) + " " + res.GetDouble(3) + " " + res.GetDouble(4) + " " + res.GetDouble(5) + " " + res.GetInt32(6)); m = new MercadoDTO(res.GetDouble(1), res.GetDouble(2), res.GetDouble(3)); mercados.Add(m); } con.Close(); return(mercados); }