Run the application

Note

Now you run the application again to test the insert, update, and delete capabilities of the second DataWindow.

  1. Click the Run button in the PowerBar.

    Run button

    PowerBuilder prompts you to save your changes.

  2. Click Yes.

    The application begins running, and the login window displays.

  3. Type dba in the User ID box.

    Type sql in the Password box and click OK.

    The database connection is established, and the MDI frame for the application displays.

  4. Select File>Report>Maintain Customers from the menu bar.

    The Customer window displays.

    Shown is the Customer window titled Maintain Customers 1. Across the top half of the screen are the column headings Customer I D, First Name, Last Name, and Company Name. They have rows of actual data and a hand icon at the left points to the top row. The bottom half of the screen shows data in labeled text boxes on the left side for Customer I D, First Name, Last Name, Company Name, and Phone Number. On the right side are labeled text boxes with data for Address and City, a drop down for State set to NJ, and then a text box with data for Zip Code.

    The top DataWindow control (dw_master) shows all of the rows retrieved from the Customer table. The hand pointer shows which row is selected.

    The bottom DataWindow control (dw_detail) shows further information about the selected customer.

  5. In the running application, click the Insert button in the toolbar

    or

    Select Edit>Insert from the Frame window menu bar.

    This clears (resets) the dw_detail DataWindow, allowing you to add information for a new row that you will insert into the data source. The cursor is in the Customer ID box in the dw_detail control.

  6. Add a new customer row by entering information in the boxes in the detail DataWindow.

    NoteTyping information for a new customer The Customer ID number must be unique. To avoid duplicate numbers, use a four-digit number for your new database entry, or scroll down the list of three-digit customer numbers in the master DataWindow and select an ID number that does not appear in the list.

    Enter values for the remaining fields.

    The phone number and zip code use edit masks to display the information you type. You must enter numbers only for these data fields. To specify the state in which the customer resides, you must click the arrow next to the state column and select an entry from the drop-down list box.

  7. Click the Update button in the toolbar

    or

    Select Edit>Update from the menu bar.

    This sends the new customer data to the database and displays a confirmation message, as coded in the script for the ue_update event.

    The new customer does not yet display in the master DataWindow. (You could add code to include this feature). However, if you open another instance of the w_customers sheet, the new customer data is visible in both the master and detail DataWindow controls.

  8. Click OK in the message box.

    Click a customer in the master DataWindow.

    That customer data displays in the lower DataWindow.

  9. Change the customer address in the detail DataWindow.

  10. Click the Update button in the toolbar

    or

    Select Edit>Update from the menu bar.

    This sends the revised customer data to the database and displays another confirmation message.

  11. Click OK in the message box.

    Select another customer in the master DataWindow.

    That customer data displays in the detail DataWindow.

  12. Click the Delete button in the toolbar

    or

    Select Edit>Delete from the menu bar.

    The customer is deleted from the DataWindow immediately but is not deleted from the database unless you select the Update option on the Edit menu. In this particular situation, the Update operation may fail, because rows in other tables in the EAS Demo DB database may refer to the row that you are trying to delete.

    You should be able to delete any row that you have added to the database.

  13. Select File>Exit from the menu bar.

    The application terminates and you return to the Window painter.

  14. Close the Window painter.