How to filter data in binding source

Posted by Kai Siegele on 19-Jul-2017 09:53


I want to show only the rows of table specifed by conditon in an abl-form in a data grid view.

For that purpose

  • I have created a new ABL form-class
  • I have added a data grid view to the form.
  • I have added a (Progress.Data.)BindingSource to the form.
  • Using the ProBindingSource-Designer I have added the table to the binding source.
  • I have specified this binding source as datasource for the data grid view.

After learning that the filter-attribute has no function  i have followed the suggestion of and wrote the following method.

METHOD PRIVATE VOID FilterRows(input cFilterString as character):




       CREATE QUERY hQuery.


       hQuery = THIS-OBJECT:bindingsource2:HANDLE.


       IF (VALID-HANDLE(hQuery)) THEN






           MESSAGE "Query not found" VIEW-AS ALERT-BOX.




       END METHOD.

Unfortunatey I get always the message Query not found. Has anyone an idea why?

Kind regards

Kai Siegele

All Replies

Posted by jquerijero on 19-Jul-2017 09:57

Just have the query handle that you originally assigned to the bindingSource defined as class level field.

Posted by Kai Siegele on 20-Jul-2017 03:57

Thanks for your answers.

After creating and initializing a new query in constructor and adding

bindingSource2:handle= hBSQuery.

the program works.

But now I want to extend my program a little bit and want to show the result of joining two tables.

For that purpose

* I have added the new table to the binding source using ProBindSource designer

* I have added the new table to the buffers of the query

* I have extended the filter string.

When invoking the program I got the exception 15607 described in

Has anyone an idea how to get the dataset from the binding source?  When invoking


I got the exception 10068.

Kind regards

Kai Siegele

Posted by Laura Stern on 20-Jul-2017 10:03

First of all, you are getting 15607 because you apparently set up the BindingSource at design time as if it were going to bind to a DataSet, giving it a parent table name, but in the end you did not bind to a DataSet.  You bound to a query, which I think is what you wanted.  Sorry, that I'm a bit unfamiliar with the design-time functionality.  So I'm not sure what it should look like when you will have a query that references multiple tables and how you set up the schema at design time to pick fields from those various tables.  That is what you need to know.  

Because you got 15607, setting the Handle property never worked, so the value of the Handle property is still null.  That is why you are getting 15607, which is telling you that the object reference in the middle of your chain (i.e., the HANDLE property in bindingsource2:HANDLE:GET-TOP-BUFFER) is resolving to the Unknown value.

And I don't understand your final question.  As I said, you are not binding the BindingSource to a DataSet.  You are binding it to a query that references multiple tables.  So why are you asking about a DataSet?  

Anyway, any DataSet or Temp-Tables live in your ABL code.  You should make them accessible via normal ABL mechanisms (i.e., having them as members of your class, etc).  You should not be accessing them via the BindingSource, which is an object that lives in .NET managed space and whose job it is to communicate between .NET controls and your ABL data.  It should not be used as a mechanism to find/get access to your ABL constructs.

Back to the design-time issue - you don't actually need to set this up at design time unless you need to size the data grid columns at design time.  Otherwise you can create the BindingSource in your Form's constructor, (see the doc for the constructors) and then binding it to the query, and then binding the DataGrid to the BindingSource (i.e., setting the DataGrid:DataSource property).

Posted by Kai Siegele on 21-Jul-2017 06:41

Hallo Laura,

thank you for your answer.

Perhaps it’s not really clear where my problem is. Let me try to explain:

In the meantime I have created my form by hand: First i have created the dataset. Then I have created buffers. Then I have attached datasources for the tables to the buffers. Then I have filled the dataset. Then I have created the query for the dataset. Then I have created the binding sources.  Then I have stuck together controls in my form and the binding sources. That was a long way to go, wasn’t it?

For saving time I want to use the ProBindignSource designer to create bindings and it’s underlying dataset. Unfortunately I have not find a way how to specify the query.

Do you have any idea?

Kind regards

Kai Siegele

Posted by Laura Stern on 21-Jul-2017 07:31

Sorry, but I still don't really understand.

You cannot create a DataSet in the ProBindingSource designer.  What you are doing there is telling the BindingSource what the schema of your existing DataSet is.  So the steps you did of creating the DataSet and the buffers, hooking them together, attaching data sources and filling the DataSet are steps that can not be eliminated!  Though of course it would be easier if you defined the DataSet statically, but maybe you can't do that.

You can still design all the visual controls in the form using Visual Designer.  But then you can create the BindingSource at runtime and bind the control to it and it to a query in your Form constructor as I said.  That is about 3 lines of code.  You would need to bind the BindingSource to the query at runtime anyway because obviously the query does not exist at design time.  And this would actually run faster then setting up the BindingSource at design time.

The thing you would be missing, as I said, is that the grid would not know the schema and therefore, you could not visually size the columns and such.  But you could also do this through the control's designer,

Your basic problem was that you set up the design-time schema as if you were going to bind to the DataSet as a whole but hen you bound the BindingSource to a single join query, not to the DataSet per se.  And the query is what you want unless you want to visually see multiple tables in the grid hierarchically.  You will need help from someone else regarding the BindingSource design time if you still want to use it and then have binding to the query  work.

This thread is closed