C# DataView RowFilter, null value for DateTime column

落爺英雄遲暮 提交于 2019-12-02 21:34:57

问题


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.

I get the following error

System.Data.EvaluateException: Cannot perform '=' operation on System.DateTime and 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. Everything before the Isnull is functioning correctly. Help please!


回答1:


Doesn't isnull always return a value of the same type as its first parameter?

Try DateBooked IS NULL instead of Isnull(DateBooked, 'Null Column') = 'Null Column'.



来源:https://stackoverflow.com/questions/5168112/c-sharp-dataview-rowfilter-null-value-for-datetime-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!