.NET BindingSource的过滤器语法参考 [英] .NET BindingSource Filter syntax reference
问题描述
您可以使用的BindingSource的Filter属性做SQL像过滤。 例如:
You can use the Filter property of a BindingSource to do SQL like filtering. For example:
bindingSource.Filter= "Activated = 1"
有什么样的文件之本的确切语法?
我要检查,如果一个字段不是DBNull的,所以我尝试现场!= NULL,但它提供了一个语法错误。
I would like to check if a field is not DBNull, so i tried "Field != NULL" but it gives a syntax error.
推荐答案
语法通常是一样的你会怎么会用在SQL Where子句,没有如果,所以在这种情况下,这将是
The syntax is generally the same as what would you would use in a SQL Where clause, without the "Where", so in this case, it would be
bindingSource.Filter = "Field <> NULL";
如果你看一下MSDN文档为BindingSource.Filter,你会看到这样的:
If you look at msdn docs for BindingSource.Filter you will see this:
,形成一个过滤器值,指定过滤的列后跟一个运算符和值的名称,接受过滤器语法取决于底层的数据源。如果基础数据源是一个DataSet,DataTable中,或数据视图,您可以指定布尔EX pressions的的使用语法文件的<一个href="http://msdn.microsoft.com/en-us/library/system.data.datacolumn.ex$p$pssion.aspx">DataColumn..::.Ex$p$pssion属性。的
"To form a filter value, specify the name of a column followed by an operator and a value to filter on. The accepted filter syntax depends on the underlying data source. If the underlying data source is a DataSet, DataTable, or DataView, you can specify Boolean expressions using the syntax documented for the DataColumn..::.Expression property."
请链接到看到所有的详细规则
Follow that link to see all the detailed rules
这篇关于.NET BindingSource的过滤器语法参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!