Important TTable properties for a single-table form

TSession methods, tutoriel & guide de travaux pratiques en pdf.

Building a sample database application: MASTAPP

This chapter is a tutorial and introduction to building Delphi database applications.
Examples show how to perform database tasks using Delphi interactively and by programming in Object Pascal. In each example you build a single form, self-contained and independent of the others. You can save yourself some work by doing the examples in sequence. Several examples use the same basic form as a starting point.
Note This material assumes you know how to use Delphi; it tells you what to do to perform certain tasks. For more details (that is, to find out why), follow the cross-references in the “For more information” section that follows each example. In particular, see Chapter 3, “Using data access components and tools.”
The tutorial consists of the following sections:
• “Building forms” describes how to use the Database Form Expert to create database forms, including single-table and master-detail forms. It also describes how to enhance forms by adding components and code by hand.
• “Working with fields” describes how to read and write field values, how to search for values and do table lookups, and how to format data displayed to the user. It also describes how to work with calculated fields.
• “Using queries and ranges” describes how to use SQL queries and set ranges to select a subset of the data in one or more tables.
• “Printing reports and forms” describes how to print ReportSmith reports and Delphi forms.

Building forms

The material in this section focuses on database issues. To learn about general application building with Delphi, see the User’s Guide. The forms described here are the basis for a database application called MASTAPP, designed to meet the record-keeping needs of the fictitious Marine Adventures & Sunken Treasures company (MAST).
MAST sells diving equipment and arranges diving expeditions. MASTAPP tracks information about customers, orders, inventory, and vendors.
The tutorial starts with a simple “codeless” form for viewing and editing table data, and works up to a full-featured invoice form containing several tables, data-aware components, and other advanced Delphi features. All the forms, tables, and related files are installed by default in C:\DELPHI\DEMOS\DB\MASTAPP. During a default installation of Delphi, an alias, DBDEMOS, that points to the MASTAPP directory is created for you, or you can create your own alias using the BDE configuration utility (see Appendix B). The following figure shows the forms and tells where they are
described in this chapter.

MASTAPP aliases

All TTable and TQuery components used in example code in this chapter set their DatabaseName property to DBDEMOS. In contrast, the complete demo in the MASTAPP directory does the following to facilitate porting:
1 The main form (MAIN.PAS) has a TDatabase component with its AliasName property set to DBDEMOS and DatabaseName property set to MAST.
2 All datasets on all forms have their Database properties set to MAST. Now all forms can use a different BDE alias simply by changing the main form’s TDatabase component’s AliasName property.
The steps in this section show how to use the Database Form Expert to build a singletable form. Of course, anything the expert does, you can do by hand, but the expert saves a lot of time.
What to do
1 Choose Help|Database Form Expert to open the Form Expert.
2 Specify a table, fields, and field layout as shown in the following figure. The Form Expert creates the form.
3 Press F9 to run the form. Click the navigator control buttons to move through the records in the table.

How it works

The Database Form Expert builds a single-table form to match your specifications, and adds a tool bar of navigation controls. The form shown in the following figure is the basis for the full-featured BRPARTS.DFM form in the MASTAPP application. The important relationships in a data-aware form like this one are the links between the underlying data, the nonvisual components, and the data controls that display data to the user.

Building a master-detail form

The steps in this section show how to use the Database Form Expert to build a form containing two tables: a master table and a detail table, linked one-to-many. This form is the basis for the CUSTORD.DFM form in MASTAPP. The master table is CUSTOMER.DB and the detail table is ORDERS.DB. You can access both tables using the MAST alias. The expert links these tables and creates components to display data for one customer at a time, and for each customer, to display many orders.

What to do

When you use the Database Form Expert, building a master-detail form is much like building a single-table form (for details, see page 21).
1 Choose Help|Database Form Expert to open the Form Expert.
2 In the first panel, specify a master-detail form that uses TTable objects.
3 In subsequent panels, specify the master table (CUSTOMER.DB), fields (use them all), and field layout (grid).
4 Specify the detail table (ORDERS.DB), fields (all), and field layout (grid).
5 Specify fields to link the master and detail tables as shown in the following figure, then tell the expert to create the form.

How it works

The expert builds a master-detail form much as it builds a single-table form (for details, see page 22). It creates TTable components and TDataSource components for the master table and the detail table and links them to the underlying data by setting properties.
The expert creates controls to display the data from each table, and sets properties to link them to the corresponding TDataSource component. The expert also creates a TDBNavigator control linked to the master table.

1.1 Database features summary
1.2 Additional Delphi Client/Server databasefeatures
1.3 Delphi data sources.
1.4 Data Access components
1.5 Data Controls components
1.6 Redistributable Borland Database Engine files
2.1 Important TTable properties for a single-table form
2.2 Important TDataSource properties for a single-table form
2.3 Important TDBGrid properties for a single-table form .
2.4 Important TDBNavigator properties for a single-table form
2.5 Important detail table properties
2.6 Important component properties for a master-detail form
2.7 Important component properties for a one-many-many form
2.8 Important TField design-time properties
2.9 Important TField design-time properties
2.10 Important TDBComboBox properties.
2.11 Important TDBComboBox properties.
2.12 Important TReport properties
3.1 TSession methods
3.2 Dataset states
3.3 Navigational methods and properties
3.4 Methods to insert, update and delete data in datasets
3.5 Methods used to work with entire records
3.6 Dataset events
3.7 TField properties
3.8 TField formatting routines
3.9 Published TField events
3.10 TField conversion functions
3.11 Important TReport methods
3.12 Batch move modes
3.13 Physical data type translations from Paradox tables to tables of other driver types
3.14 Physical data type translations from dBASE tables to tables of other driver types
3.15 Physical data type translations from InterBase tables to tables of other driver types
4.1 Data controls 
4.2 Expanded TDBGrid Options properties
4.3 TDBGrid events
4.4 TDBNavigator buttons
4.5 Data-aware list box and combo box  controls
5.1 Types of query result sets
6.1 Server transaction isolation levels
6.2 Oracle SQL Link files
6.3 Sybase SQL Link files
6.4 Informix SQL Link files
6.5 InterBase SQL Link files
6.6 Winsock 1.1 client files
6.7 Non-Winsock compliant TCP support files

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *