Try OpenEdge Now
skip to main content
GUI for .NET Programming
Notes on using the ProBindingSource : Repopulating data in an ABL data source bound to a ProBindingSource
 

Repopulating data in an ABL data source bound to a ProBindingSource

If an application needs to repopulate the data in the underlying ABL data source that is bound to a ProBindingSource, you can accomplish this in several different ways. For example:
*You can execute new QUERY-PREPARE( ) and QUERY-OPEN( ) methods on the query that the ProBindingSource is bound to.
Because the ProBindingSource is directly bound to the query that was just reopened, you do not have to do anything further as long as the ProBindingSource's AutoSync property is set to TRUE (which is the default). If the property is set to FALSE, simply call myBindingSource:RefreshAll( ) to notify the control to refresh.
*You can empty and repopulate a temp-table by executing a new query on the database and then creating appropriate temp-table records.
If you choose this option, you must reopen the query the ProBindingSource is bound to (that is, the query on the temp-table). This is important: Even though the query criteria has not changed (it is still for each temp-table record), the ProBindingSource must be working from the right query result set in order for the control to show the correct records. In particular, having the correct count of records in the result set is critical.
Reopening the query takes care of this, and you must call myBindingSource:RefreshAll( ) to notify the control to refresh.
To empty a control bound to a ProBindingSource, the application must modify the query, so that no records satisfy it, and then reopen it. (Neither closing the query nor setting the Handle property to the Unknown value (?) is sufficient.)
For example, here is a typical query that would empty the result set:
FOR EACH Customer WHERE ROWID (Customer) = ?:
Here is another way to repopulate the data; however, this approach is highly inefficient and not recommended:
1. Unbind the control from the ProBindingSource. For example:
myControl:DataSource = ?
2. Disconnect the ProBindingSource from its data source. For example:
myBindingSource:Handle = ?
3. Update the data in the ABL data source; for example, repopulate the temp-table or reopen a query.
4. Re-establish the bindings.
While this series of steps does accomplish the task at hand, it is inefficient for the following reasons:
*When you set myBindingSource:Handle to the Unknown value (?) as shown in step 1, all of the underlying .NET objects that make the ProBindingSource function are deleted. When the Handle property is reset as shown in step 2, these objects are recreated and again need to communicate to the AVM to get the schema of the underlying data source.
*The .NET control itself is doing work to destroy and re-establish its bindings.