I have this code that counts the number of records with the same year and date. But when I run the application it doesn't work. Here is my code:
try
{
string query = "SELECT * FROM tblOrder WHERE dateTime_coded=@dateTimeNow";
MySqlCommand cmd = new MySqlCommand(query, con);
cmd.Parameters.AddWithValue("@dateTimeNow", Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM"));
MySqlDataReader dr = cmd.ExecuteReader();
MessageBox.Show("OK");
con.Open();
while (dr.Read())
{
count++;
}
dr.Close();
con.Close();
}
catch (Exception)
{
}