Setting up a Data Window in PowerBuilder
Setting up a Data Window in PowerBuilder
A data window represents a graphical interface that the user
can work with to retrieve, update, and create data for
tables on an SQL server. Setting up a data window in
PowerBuilder can be an involved exercise. While it is a
conceptually simple task, the graphical manipulation may
make this a time-consuming task. Nonetheless, with a little
effort (and some common human-computer interaction principles),
the results can be quite aesthethic, and the overall process
rather stimulating.
This task requires that the following have been performed:
- an application has been created, with appropriate library
- a valid database profile exists
- you are logged in to the database server, and the database
- the tables for the data window have been created
Creating the DataWindow
Select the DataWindow painter icon
from the PowerBar. You should receive a standard window listing available
data windows. Select New to create a new data window.
As a default, the Quick Select and Freeform options are
selected. These represent the source of the data, and the manner in which
it is to be presented to the user. For the initial data window to be created,
these defaults are acceptable. As you get more familiar with this painter,
you can experiment with other options. Select OK at this point,
and PowerBuilder will put up a Quick Select window.
Select the appropriate table, and the columns that you wish to appear in
the data window. Upon selecting OK, you will be presented with
an initial layout for the data window.
This data window can be embellished quite easily, to make for a more
pleasing view. Additional text and objects can be placed on the data
window using the drawing tool bar on the left. Objects can be moved
by simply selecting them and dragging them to the desired locations.
Resizing of objects is performed using the standard Windows practice,
i.e. selecting, grabbing an edge or corner, and dragging to the
appropriate size.
The properties (color, font, border, layer, etc.) of each object can
also be varied by selecting the object, displaying its properties (using
the right mouse button), and then setting the properties to the desired
value.
An improved version of the employee data window appears below.
After the changes have been made, and the data window is laid out
as desired, it can be saved, using the Save option under the
File menu. Alternatively, attempting to close the data
window without saving will generate a query as to whether it is to be
saved. The Save DataWindow screen appears below.
As a general rule, datawindows should be saved with a d_
prefix, and this one is saved as d_empscreen. As usual,
comments are always helpful at this stage.
Using the DataWindow
The data window can be used to view, insert, and update data,
directly. This presumes that the user knows which data segments
from which table is being manipulated. For simple applications, with
very few tables this is acceptable. For more complex apllications,
or windows involving several tables, this may not be such a good
idea. In those situations, creating an application window, with
appropriate scripts, may be prefereable.
To insert data into the employee using the
d_empscreen data window, select the Preview icon
from the toolbar at the left. Since there are no records in the table,
an empty data window is presented. Data can be inserted in to
the table via the Insert Row icon
.
The cursor will shift to the first field in the data window, and you
can add a record.
This process allows you to add a record at a time, and you must
use the Insert Row icon continually. The table can be saved via the
Save changes icon. Alternatively, if you attempt to quit without
saving, PowerBuilder will prompt you as to whether you wish to save
the data or not.
You've just set up a data window, and used it to manipulate
data on a remote SQL server!
 
Client/Server Tools |
Software Tools
© Derek Nazareth, (with input from Jungjoo Jahng), last updated on
November 11, 1997.