.NET BindingSource Filter syntax reference
Asked Answered
B

3

9

You can use the Filter property of a BindingSource to do SQL like filtering. For example:

bindingSource.Filter= "Activated = 1"

Is there something like documentation on the exact syntax of this?

I would like to check if a field is not DBNull, so i tried "Field != NULL" but it gives a syntax error.

Bunton answered 7/9, 2009 at 15:15 Comment(0)
H
11

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";

If you look at msdn docs for BindingSource.Filter you will see this:

"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

Hygrometry answered 7/9, 2009 at 15:18 Comment(0)
A
4

Have a look at this msdn article. The described syntax should be valid for your BindingSource, too.

Artel answered 7/9, 2009 at 15:20 Comment(0)
M
2

What worked for me was

bindingSource.Filter = "columnName Is Null";

or conversely

bindingSource.Filter = "columnName Is Not Null";
Melone answered 23/2, 2012 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.