Using FieldsXXX Properties

The tool IB_WISQL will be used in this tutorial. It is the component editor for design-time use so you are actually learning how to program with IBO at the same time.

First of all you must have an active connection with a database. This can be accomplished on the "Connection" page of the IB_WSQL main window. Type the database name or select database file using Lookup… button. In our sample we will use the Employee.gdb file that comes with Delphi and/or InterBase as a sample database.

After that specify your Username and Password, SQL Role and CharSet if necessary, click the "Connect Database" button on the toolbar. Once a connection is established you'll see some database parameters and the "Connect Database" button changes to a "Disconnect Database" button.

If something was incorrectly entered an error dialog will be displayed. It possibly means that you need to: a) check the path to your database, b) verify your username and password, c) start InterBase server ;)

If you want to browse the contents of a database just click the Browse button on toolbar. In here you can learn the tables, views, stored procedures, domain names, generators, etc. and their structures. This inforamtion can be used to make decisions about how to obtain necessary data.

In our sample we'll use the EMPLOYEE table for some simple tasks select and view all EMPLOYEE data in a customized fashion. For this we must take several steps:

1)Select Query Forms page on IB_WISQL main window and type name for new Query Form (for instance "Employee"). Then click the New button and select it in the list after adding it. Then press the Launch button to start this new Query Form. First that you see is Tabbed Notebook with separate page for each property of the DataSet. It also includes toolbars with many options so that we can make some pages contain additional notebook.  
2)Type on SQL page of SQL page: "SELECT * FROM EMPLOYEE" (without any brackets), then press Prepare Dataset button. In the bottom memo a "PLAN (EMPLOYEE NATURAL)" message appears. Great! Go to page Data and see result! Don't confuse, to see all data use Goto Last Row button on taskbar. Dependently of size your monitor you can see part of grid containing RAW data in default presentation. Let's try improving its view.  
3)Go to FieldList page next to the SQL page and copy all available fields to clipboard for future use, then select Field Properties page. This page contains its own notebook opened on Alignment page, but we'll not use alphabetical order and start from DisplayLabel property.  

Paste fields list on DisplayLabel page and type text like this:  
EMP_NO= Employee #  
FIRST_NAME= First Name  
LAST_NAME= Last Name  
PHONE_EXT= Phone ext.  
HIRE_DATE= Hire Date  
DEPT_NO= Department  
JOB_CODE= Job Code  
JOB_GRADE= Job Grade  
JOB_COUNTRY= Job Country  
SALARY= Salary ($)  
FULL_NAME= Full Name  
Note: No spaces between field name and "=" sign.  

4)If you don't want change labels of some fields in view, delete these fields from list. Take look on Data page looks better doesn't it?  
5)For more, let's change DisplayFormat for some fields: on DisplayFormat page type:  

EMP_NO="#" ###  
SALARY= # ### ### ##0.00  

Note: No spaces between field name and "=" sign.  
Don't forget look on Data page. You can customize DisplayFormat property for other fields later and now go to Alignment page:  
6)Set Alignment property as follows:  


Abbreviations means: L(eft), R(ight), C(entered). If no alignments assigned then the default settings are used.  

7)Maybe the CharCase of some column doesn't satisfy your needs you can change it. In the CharCase property page type:  


Abbreviations means: P(roper), U(pper), L(ower), N(ormal). If no CharCase value is assigned then the default settings are used.  

8)If you plan to edit selected data the EditMask property can help you do it more comfortably. Especially for the Date field type. For specifying EditMask property go to its page and type:  


MaskEdit property specification the same as for Delphi's MaskEdit controls.  

9)To prevent occasionally changing important data such as SALARY we prevent editing in this column by setting ReadOnly property to T(rue):  


Try editing this field. Your data is more safe then ever! You may need to add the FOR UPDATE clause to the end of the SELECT statement so that it is an updatable dataset. This is the same as setting RequestLive to true.  

10)Next step we can do is hiding some fields from view WITHOUT SQL! On Visible property page type:  


Settings are T(rue) and F(alse) accordingly where true is the default setting. Second row is not necessary but easy to use when you decide hide this column in future.  

11)Take a look at our data, all columns are displaying correctly but some columns are too wide and the fields order is incorrect. Don't worry, just resize and move columns as you wish right in the grid! Your changes will be shown in DisplayWidth and Index property pages.  

Look finally on our job this great tool gives us perfect results! You can return to it every time by selecting from Query Forms list. Changes are saved between sessions in the system registry.

And good news for all who decide write own programs using IB_Objects QueryForms is available for IB_Query component by double clicking at design time! Then, instead of saving criteria in the system registry it is saved in your component at design-time.