private void ShowButton (object sender, EventArgs e) { String constring ="datasource=;port=;username;password="; using (var conn = new MySqlConnection(constring)) { BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; bs.Filter = "Convert(Date,'System.String') Between '%" + dateTimePicker1.Text + "%' AND '%" + dateTimePicker2.Text + "%' "; dataGridView1.DataSource = bs; } }
DataColumn.Expression
bs.Filter = string.Format("Date Between #{0:yyyy/MM/dd}# And #{1:yyyy/MM/dd}#", dateTimePicker1.Value, dateTimePicker2.Value);
>=
<=
bs.Filter = string.Format("Date >= #{0:yyyy/MM/dd}# And Date <= #{1:yyyy/MM/dd}#", dateTimePicker1.Value, dateTimePicker2.Value);
bs.Filter = string.Format("YOUR_COLUMN_NAME_HERE >= #{0:yyyy/MM/dd}# And YOUR_COLUMN_NAME_HERE <= #{1:yyyy/MM/dd}#", dateTimePicker1.Value, dateTimePicker2.Value);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)