Mastering PowerBuilder
Where To Use a DataStore?
There are three main areas where you can use DataStore instead of a DataWindow control.
- Background Processing: Sometimes we use multiple DataWindow controls on the screen to display one single report. An example for this would be transactions window in our application. Those DataWindows are not usable for printing. So, we use a hidden DataWindow control for printing. By using the hidden DataWindow control, we are putting all the visual overhead. It would be more efficient to use DataStore instead of hidden DataWindow control, by that we are reducing a lot of overhead.
- Processing Embedded SQL: Lot of times you need to use embedded SQL to check whether a particular record is existing in the database or not. For example, when the user enters a new product in the product_master, in the ItemChanged event of that DataWindow control, we are checking for the existence of the newly entered product. If it's already existing in the database, we are displaying an error. Well, we are using a hidden DataWindow control in this case. Some people use embedded SQL instead of hidden DataWindow control. It would be more efficient if you use DataStore instead of embedded SQL/hidden DataWindow control.
- Distributed Objects: You can use DataStore in the server application when you are developing a distributed application. More details on this topic are covered in the "Distributed Objects" session.