求救:时间段查询,就是提示数据类型不匹配
代码如下:
DateTime dtStart = dateTimePicker1.Value;
DateTime dtEnd = dateTimePicker2.Value;
strSQL = "SELECT * from 记录 WHERE 时间 BETWEEN ' "+dtStart+ " ' and ' "+dtEnd+ " ' ";
提示“标准表达式中数据类型不匹配”,请大侠指点!
------解决方案--------------------strSQL = "SELECT * from 记录 WHERE 时间 BETWEEN ' "+dtStart+ " ' and ' "+dtEnd+ " ' ";
------
时间 什么类型??
------解决方案--------------------追踪下dateTimePicker1.Value ,看得到的是不是 'yyyy-mm-dd '格式!
注意年月日必须有才可以进行时间超作.
------解决方案--------------------strSQL = "SELECT * from 记录 WHERE 时间 BETWEEN # "+dtStart+ "# and # "+dtEnd+ "# ";