Delphi - Creating a Database Application using Delphi.pdf

(385 KB) Pobierz
121232580 UNPDF
Tutorial: Creating a
Database Application
using Delphi
Borland ®
Kylix 3
Delphi and C++ for Linux ®
Borland International, Inc., 100 Borland Way
P.O. Box 660001, Scotts Valley, CA 95067-0001
www.borland.com
121232580.001.png
C OPYRIGHT © 2001–2002 Borland Software Corporation. All rights reserved. All Borland brand and product names
are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries.
All other marks are the property of their respective owners.
K3-Delphi_DB-0702
Contents
Creating a database application using
the Delphi IDE
Overview of database architecture . . . . . . . . 1
Creating a new project . . . . . . . . . . . . . . . 2
Setting up data access components . . . . . . . . 3
Setting up the database connection . . . . . . 3
Setting up the unidirectional dataset . . . . . 4
Setting up the provider, client dataset,
and data source . . . . . . . . . . . . . . . . 5
Designing the user interface . . . . . . . . . . . . 6
Creating the grid and navigation bar . . . . . 6
Adding support for a menu . . . . . . . . . . 8
Adding a menu . . . . . . . . . . . . . . . . . 9
Adding a button . . . . . . . . . . . . . . . . 11
Displaying a title and an image . . . . . . . . . 12
Writing an event handler . . . . . . . . . . . . . 13
Writing the Update Now! command
event handler . . . . . . . . . . . . . . . . . 13
Writing the Exit command event handler . . 14
Writing the FormClose event handler . . . . 14
Index
iii
121232580.002.png
iv
Chapter0
Creating a database application
using the Delphi IDE
This tutorial guides you through the creation of an InterBase database application
with which you can view and update a sample employee database. You will use the
Delphi IDE to create the database application.
This tutorial assumes you are familiar with Linux and have read the introduction to
Kylix programming and the IDE in the Quick Start .
Note This tutorial is written for the Kylix Enterprise and Professional editions, which
include the database components. You must have InterBase installed to successfully
complete this tutorial.
Overview of database architecture
The architecture of a database application may seem complicated at first, but the use
of multiple components simplifies the development and maintenance of actual
database applications.
Database applications include three main parts: the user interface, a set of data access
components, and the database itself. In this tutorial, you will create a dbExpress
database application. Other database applications have a similar architecture.
The user interface includes data-aware controls such as a grid so that users can edit
and post data to the database. The data access components include the data source,
the client dataset, the data provider, a unidirectional dataset, and a connection
component. The data source acts as a conduit between the user interface and a client
dataset. The client dataset is the heart of the application because it contains a set of
records from the underlying database which are buffered in memory. The provider
transfers the data between the client dataset and the unidirectional dataset, which
fetches data directly from the database. Finally, the connection component
Creating a database application using the Delphi IDE 1
121232580.003.png
Zgłoś jeśli naruszono regulamin