通过两个dateTimePicker1日期控件查找数据库日期段的内容,一直没成功?
//获取DateTimePicker日期DateTime a = Convert.ToDateTime(dateTimePicker1.Text);
DateTime b = Convert.ToDateTime(dateTimePicker2.Text);
string cmdStr = "select * from 历史记录 where 日期/时间 between '" + a + "' and '" + b + "' ";
while (conn.State != ConnectionState.Open)
conn.Open();
DataSet ds1 = new DataSet();
OleDbDataAdapter da1 = new OleDbDataAdapter(cmdStr, conn);
da1.Fill(ds1);
this.dataGridView1.DataSource = ds1.Tables[0];//数据源里的第一张表
测试了好多种方法都不行?
截图: