Logon to Data Source

Before we can access the data in our database through the data source, we first have to execute the ProLinga command "SQL CONNECT" to open a connection to the data source for this session. Since we will be accessing our data throughout the application, it is best to place this command at the very beginning of our application. Remember that the starting point of our application was logic called "Main". Bring up this logic in the logic editor and add the following line to it:


The name "netadm" is the name of the data source object that we created in the previous chapter. Your logic "Main" now should look as follows:

Figure51.Logic With SQL CONNECT

Screenshot of the logic Main with SQL CONNECT.

Similar it is good practise to close a data source upon exiting from or logging out of the application. Therefore it is a good idea to write a logic block that is called every time the user exits or logs out from the application. Write a logic block named "Quit" as follows:

Figure52.Logic "Quit" With SQL DISCONNECT

Screenshot of the logic Quit with SQL DISCONNECT.

Write the same logic and save it with the name "Logout".

Figure53.Logic "Logout" With SQL DISCONNECT

Screenshot of the logic Logout with SQL DISCONNECT.

Make sure you do not overwrite the logic called "Main" and that you press the button New in the logic editor first before writing this new logic.

Now we have to make sure that this logic gets called when the user exits/logs out from the application. The only way the user can exit the application is through the pulldown menu option "Quit" and "Logout" or through the toolbar button "Quit". Currently, we have linked that to C-exit and C-logout, but if we change that to L-Quit and L-Logout, our new logic block "Quit" or "Logout" will be called upon exit/logout. To change this, open the screen "Main" in the Screen Editor and start the painter. To update the link from the button "Quit", single click on the button, go to the properties screen and press the tab "Signals". Update the handler field to L-Quit.

Figure54.Update Toolbar Button Signal Handler

Screenshot of how to update the toolbar button signal handler.

Update similar way the pulldown menu entry "Quit" and "Logout".

Figure55.Update Pulldown Menu Item Signal Handler

Screenshot of how to update the pulldown menu item signal handler.

Save the screen and test your application.