Trying to make a Query to Query a Database and return the rows using the DatetimePicker in C# Winform. It returns a very empty row when i click the date.
My code looks like this
private void dateTimePicker_ValueChanged(object sender, EventArgs e)
{
string constring = ConfigurationManager.ConnectionStrings["MySQLDatabaseConnection"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(constring))
{
string sql = "SELECT CAST(visit_date AS DATE) AS VISIT_DATE WHERE visit_date='" + dateTimePicker.Value.Date + "'";
try
{
con.Open();
MySqlDataAdapter da = new MySqlDataAdapter(sql, con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Am i missing something?