![]() |
![]() |
![]() |
![]() |
Displaying database results
Now we will display the results of your search in your user interface.
On the left of the screen you will see a tree with two items at the top level: "Database Connection" and "inStock". The "Database Connection" area has 6 items in it, including a database action called "Open Connection". You can map a a database action to a button by selecting the action in the tree and then selecting the button in the list on the left.
We will now map the "Open Connection" database action to a button, so that your program can open a connection to the database before it performs the search.
- Select the "<Open Connection>" item in the tree. You will see a list of items on the right which can open a database connection when they are activated.
- Select "connect", the button which you set up previously, by clicking on it once in the list. It will now open a connection when it is pressed.
The tree will immediately update to show that the connect button will open a connection.
Next we will set up the display of the information from the database.
- Click on "PRODUCT_NUM" in the tree (under inStock). The list to the right will show possible objects which may display the information in the PRODUCT_NUM column.
- Choose "productNumber", the textfield you created earlier, by clicking on it once in the list. The tree will update to show that the PRODUCT_NUM column will be displayed in "productNumber".
- Click on "DESCRIPTION" in the tree.
- Choose "description" from the list to the right.
- Map "PURCHASE_COST" in the tree to "purchaseCost" in the same manner.
- Map "QTY_ON_HAND" in the tree to "quantityOnHand" in the same manner.
- Click on "<Execute Statement>" in the tree. You want the search to be performed when the button called "showAvailable" is pressed.
- Choose "showAvailable" from the list to the right.
Since TextFields can only show one row at a time, you need a way to go forward and backwards among the rows.
- Map the "< Goto Previous Record >" action in the tree with the "previous" button from the list on the right.
- Map the"< Goto Next Record >" action in the tree with the "next" button from the list on the right.
If you make a mistake, you can always deselect something from the list on the right by clicking it again.
- Press the "Apply changes" button in the bottom right-hand corner to update your user interface with the changes you have made.
You may now close the database editor.
You have now finished creating a program which connects to a database, sends a query to it, and displays the results. Let's test it.
- Press the "connect" button in your program to connect to the database.
- Press "show available items" button to perform the search.
The "previous" and "next" buttons will let you browse through the resulting records.
Data Representations, Inc. http://www.datarepresentations.com support@datarepresentations.com sales@datarepresentations.com |
![]() |
![]() |
![]() |
![]() |