Hi!
I have a form with two dateTimePickers (first with date of one month ago, and the secod with current date), a dataGridView and a button.
When i click the button i want to populate the dataGridView, but only between date1 and date2
mySqlCommand = con.CreateCommand();
mySqlCommand.CommandText = "SELECT * FROM MyTable WHERE (MyDate BETWEEN @date1 AND @date2)";
mySqlCommand.Parameters.Add("@date1", SqlDbType.Char);
mySqlCommand.Parameters["@date1"].Value = dateTimePicker1.Text.ToString();
mySqlCommand.Parameters.Add("@date2", SqlDbType.Char);
mySqlCommand.Parameters["@date2"].Value = dateTimePicker2.Text.ToString()
I get this error "Must declare the scalar variable "@date1".
Can anyone help me, please?