I have a group of buttons like 48 of them.
In the form load event, I take all the button text values from each button to run a query, which is done using "for loop and array".
This is my work so far.
Button[] btnarray = { button1, button2, button3, button5, button6};
for (int j = 0; j <= btnarray.Length; j++)
{
MySqlConnection con = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["db"].ConnectionString);
con.Open();
string query = "SELECT carplate FROM billing WHERE carplate='" + btnarray[j].Text + "' AND dates=DATE(NOW())"; // This is where i get error.
MySqlCommand command = new MySqlCommand(query, con);
var reader = command.ExecuteReader();
if (reader.Read())
{
btnarray[j].BackColor = Color.Red;
}
else
{
btnarray[j].BackColor = Color.Khaki;
}
}
Any help is appreciated.