N3lson Posted February 2, 2017 at 12:07 PM Report Share #602279 Posted February 2, 2017 at 12:07 PM Boas estou a tentar colocar as datas (recolhidas de uma base de dados) no calendário a negrito, se colocar apenas um registo funciona bem mas se colocar mais que 1 registo retorna-me no calendário apenas o mais recente. Podem me ajudar ? string _query = "SELECT * FROM calendario WHERE estado=1 AND utilizador=@user;"; using (MySqlConnection con = new MySqlConnection(ConSql)) { using (MySqlCommand cmd = new MySqlCommand(_query, con)) { con.Open(); cmd.Prepare(); cmd.Parameters.AddWithValue("@user", Sessao.Id); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DateTime data = (DateTime)reader["dataAviso"]; int ano = data.Year; int dia = data.Day; int mes = data.Month; monthCalendar1.BoldedDates = new System.DateTime[] { new System.DateTime(ano, mes, dia) }; } reader.Close(); } } con.Close(); } Obrigado You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it. Link to comment Share on other sites More sharing options...
N3lson Posted February 2, 2017 at 12:26 PM Author Report Share #602282 Posted February 2, 2017 at 12:26 PM Já resolvi string _query = "SELECT * FROM calendario WHERE estado=1 AND utilizador=@user;"; using (MySqlConnection con = new MySqlConnection(ConSql)) { using (MySqlCommand cmd = new MySqlCommand(_query, con)) { con.Open(); cmd.Prepare(); cmd.Parameters.AddWithValue("@user", Sessao.Id); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { monthCalendar1.AddBoldedDate(DateTime.Parse(funcao.OutHoras(reader["dataAviso"].ToString()))); } reader.Close(); } } con.Close(); } You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now