LazDoc - Update to DBCtrls (HowToUseDataAwareControls)

git-svn-id: trunk@13658 -
This commit is contained in:
kirkpatc 2008-01-06 17:32:38 +00:00
parent 464160182d
commit 19dbef9d83

View File

@ -4464,10 +4464,10 @@
<seealso/>
</element>
<topic name="HowToUseDataAwareControls">
<short><i>HowToUseDataAwareControls</i> - Hints for accessing databases</short>
<short><i>HowToUseDataAwareControls</i> - Hints for accessing databases</short>
<descr>
<p><i>HowToUseDataAwareControls</i> - Hints for accessing databases. A set of Data-Aware components is provided, to make it easier to access information held in databases.</p>
<p>Before using Data-Aware components, it is necessary to make a connection with a database, and this should be done either using a TSQLConnection or a TDBf component, depending on the type of database that is being used. In any case, the components for connection with the database need to be found in $Lazdir/components/sqldb/ or whatever other source is appropriate. They need to be added using the <i>Components</i> Menu Item of the IDE, and compiled ready for adding. The IDE needs to be re-built to include the new components.</p>
<p>Before using Data-Aware components, it is necessary to make a connection with a database, and this should be done either using a TSQLConnection or a TDBf component, depending on the type of database that is being used. In any case, the components for connection with the database need to be found in $Lazdir/components/sqldb/, $Lazdir/components/tdbf/ or whatever other source is appropriate. They need to be added using the <i>Components</i> Menu Item of the IDE, and compiled ready for adding. The IDE needs to be re-built to include the new components.</p>
<p>To make the connection with the database: first place a <i>DataBase Connection</i> on the Form (invisible at run-time, so put it anywhere convenient); set its properties to connect the user (with name and password) to the appropriate server, database and table (the connection component should deal with all the user-authentication issues, opening and closing the database etc). Then put on a <i>TDataSource</i> from the Data Access tab of the Component Palette, and perhaps items such as <p>TSQLTransaction</p> and <p>TSQLQuery</p>, depending on the particular database you are using. The various database components need to be linked to each other, for example by setting the <i>Transaction</i> property of a database connector to the appropriate transaction component, and linking the <i>DataBase</i> property of the Transaction component back to the database connector; link the DataSource's <i>DataSet</i> property to the appropriate SQLQuery or other set of data, and its <i>Transaction</i> property to the transaction component</p>
<p>Each Data-Aware control (on the Data Controls tab of the Component Palette) has the usual set of properties to determine its shape and size, position, colour and font etc. But there are also special properties to define the data to be displayed or modified. These include the <i>DataSource</i> property which must be set to link to the defined set of data, and often a <i>Field</i> component to determine which of the columns in the database is to be displayed. </p>
<p>Most of the components operate on a single Row or record of the database, but the <i>TDBGrid</i> is capable of displaying and operating on multiple rows and columns, in a <i>StringGrid</i> format, allowing the user to get an overview of what is in the database. The DBGrid will display the contents of the DataSet even at design time, provided the various components are enabled or rendered active; this allows the designer to ensure that all the connections to the database have been correctly made.</p>
@ -4480,6 +4480,70 @@
<li>at intervals usually prescribed by the user (sometimes after every change, sometimes after a whole series of changes), the contents of the local DataSet are sent back to the database, causing an update of the database's contents. This process is referred to as 'Commit' or 'Post' or sometimes as 'Update'</li>
</ul>
<p>The programmer can determine which events are associated with a Commit action by supplying suitable event handlers for <i>OnClick</i>, <i>OnChange</i>, <i>OnFinishedEdit</i> etc.</p>
<p>The following table shows the approximate correspondence between conventional and data-aware control classes</p>
<table>
<th>
<td>Standard Control</td>
<td>Data-Aware Control</td>
<td>Comment</td>
</th>
<tr>
<td>TCalendar</td>
<td>TDBCalendar</td>
<td>Select a date from pop-up calendar</td>
</tr>
<tr>
<td>TCheckBox</td>
<td>TDBCheckBox</td>
<td>Check a box to show an option has been selected</td>
</tr>
<tr>
<td>TComboBox</td>
<td>TDBComboBox</td>
<td>Select an option from a list and return it (or some custom text) in the main edit box</td>
</tr>
<tr>
<td>TEdit</td>
<td>TDBEdit</td>
<td>Single-line text editing box</td>
</tr>
<tr>
<td>TGroupBox</td>
<td>TDBGroupBox</td>
<td>A container for several related controls</td>
</tr>
<tr>
<td>TImage</td>
<td>TDBImage</td>
<td>A Picture</td>
</tr>
<tr>
<td>TListBox</td>
<td>TDBListBox</td>
<td>A list of string items</td>
</tr>
<tr>
<td>TMemo</td>
<td>TDBMemo</td>
<td>Multiple-line text editing box</td>
</tr>
<tr>
<td>TRadioGroup</td>
<td>TDBRadioGroup</td>
<td>A group of mutually exclusive Radio Buttons; only one at a time may be checked and selected. Note there is no data-aware equivalent of the isolated TRadioButton</td>
</tr>
<tr>
<td>TText</td>
<td>TDBText</td>
<td>A simple text-string, usually read-only</td>
</tr>
<tr>
<td>TStringGrid</td>
<td>TdbGrid</td>
<td>A grid to display information in Rows and Columns</td>
</tr>
</table>
<p>Standard Controls can, of course, be used to display information from a database, but they lack the direct link with the DataSet and its Navigation aids, so the programmer must write explicit code to extract data from the DataSet and put it in the Standard Control</p>
</descr>
</topic>
</module>