views:

2004

answers:

3

Hello, you can use the Filter property of a BindingSource to do SQL like filtering. for example

bindingSource.Filter= "Activated = 1"

but is there something like a documentation on the exact syntax of this?

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

thanks!

+4  A: 

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

Charles Bretana
A: 

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

tanascius
A: 

When Filter is not null a null reference, the BindingSource passes this property to the underlying list.

If you're bound to a DataTable or a DataView, the syntax would be the one available at DataColumn.Expression Property.

Alfred Myers