如何使用c#中的bindingsource将数据表从特定日期过滤到特定日期?

时间:2015-09-08 19:15:22

标签: c# mysql visual-studio-2010

 tennisBindingSource.Filter = "Booking_Date <= '" + dateTimePicker1.Value.ToShortDateString() + 
"# Booking_Date > #" + dateTimePicker1.Value.ToShortDateString() + "#";

我得到的错误无法在system.datetime和system.string上执行'&gt; ='操作

1 个答案:

答案 0 :(得分:0)

错误导致您的Booking_Date类型为datetime,并且您尝试与字符串进行比较。而是将您的代码更改为如下所示。请勿将其转换为ToShortDateString()dateTimePicker1.Value会返回DateTime个实例。

tennisBindingSource.Filter = "Booking_Date <= " + dateTimePicker1.Value