0
I cannot get feedback from my select in the database. Where I show the data in a listview.
using (_connection = new MySql.Data.MySqlClient.MySqlConnection("Database=roubo_furto; Data Source=192.168.0.17;User Id=RFID;Password=1234;SslMode=None;"))
{
System.Text.EncodingProvider ppp;
ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);
_connection.Open();
var cmd = new MySqlCommand("SELECT distinct id, Carro, Placa, " +
"Fabricante, Ano, Cor, Data FROM tcc " +
"WHERE DATE_FORMAT(Data,'%d/%m/%Y') = STR_TO_DATE(" + txtDate.Date.ToString("dd/MM/yyyy") +
", '%d/%m/%Y')", _connection);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
listView.Items.Add("Ocorrencia: Nº " + reader.GetString(0) + " " + "\nData: " + Convert.ToDateTime(reader.GetString(7)).ToString("dd/MM/yyyy") + " " + "\nCarro: " + reader.GetString(2) + " " + "\nPlaca: " + reader.GetString(3) + " " + "\nCor: " + reader.GetString(6) + " " + "\nAno: " + reader.GetString(5) + " " + "\nFabricante: " + reader.GetString(4) + "\n\n");
}
}
<DatePicker x:Name="txtDate" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="0,208,0,0" VerticalAlignment="Top" Width="415" ToolTipService.ToolTip="" MonthFormat="{}{month.solo.full}">
Add all the code, please, including the part where Voce assigns the data pro Reader. But, if you are assigning certificate, I would test: Reader["id"], Reader["Date"]...
– Aline
I added more information
– Jon
Utlize Paramenters it does all conversion...
– novic