本文介绍了DataView筛选器C#中无法包含(-)破折号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据表中有一列,其中columname是最后更新的",并且我试图将列名与下面的过滤器一起使用

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

我试图用单引号括住列名,但仍然无法正常工作.

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

推荐答案

我认为-的行为就像算术运算符,并且此RowFilter认为lastupdated是两个不同的列,您尝试计算它们的差.

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.

只需将它们用[]包装为[last-updated]就可以了.

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

这篇关于DataView筛选器C#中无法包含(-)破折号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:51