Unable to Have (-) Dash in DataView Filter C#

独自空忆成欢 提交于 2019-12-12 01:36:41

问题


I have a column in datatable where the columname is "last-updated" and I am trying to use the column name with filter like below

dv.RowFilter = " (last-updated >= #" + Convert.ToDateTime(dateTimePickerStart.Text).ToString("MM/dd/yyyy") + "# And Date <= #" + Convert.ToDateTime(dateTimePickerEnd.Text).ToString("MM/dd/yyyy") + "# ) ";

When I try to build I am getting

"Cannot find colum [last]".

I have tried to add single quote arrounding the column name but still not working.


回答1:


I think - acts like an arithmetic operator in your case and this RowFilter thinks that last and updated as a two different columns and you try to calculate their differences.

Just wrap them with [] as [last-updated] in it should be fine.



来源:https://stackoverflow.com/questions/34628778/unable-to-have-dash-in-dataview-filter-c-sharp

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