简体   繁体   English

C#DataView RowFilter,DateTime列的空值

[英]C# DataView RowFilter, null value for DateTime column

I'm trying to filter on null columns (I only want to show rows where the column is null), but the issue is I can't compare the column to a null, since the column is of DateTime value. 我正在尝试过滤空列(我只想显示列为空的行),但问题是我无法将列与null进行比较,因为该列是DateTime值。

I get the following error 我收到以下错误

System.Data.EvaluateException: Cannot perform '=' operation on System.DateTime and System.String. System.Data.EvaluateException:无法对System.DateTime和System.String执行'='操作。

This is my code for the filter 这是我的过滤器代码

CourseID IN (" + courseIds + ") AND Isnull(DateBooked, 'Null Column') = 'Null Column'

DateBooked is the column with DateTime value. DateBooked是具有DateTime值的列。 Everything before the Isnull is functioning correctly. 在Isnull正常运作之前的一切。 Help please! 请帮助!

Doesn't isnull always return a value of the same type as its first parameter? isnull是否始终返回与其第一个参数相同类型的值?

Try DateBooked IS NULL instead of Isnull(DateBooked, 'Null Column') = 'Null Column' . 尝试DateBooked IS NULL而不是Isnull(DateBooked, 'Null Column') = 'Null Column'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM