Upload
domenic-black
View
249
Download
12
Tags:
Embed Size (px)
Citation preview
Developing Win32 Database Applications with DelphiCary Jensen
Jensen Data Systems, Inc.
Overview
General Comments About Delphi’s Data Access Technologies
Overview of Data Access Technologies The Borland Database Engine dbExpress dbGo (ADO) MyBase InterBase Express DataSnap Third-Party Data Access Options
Data Modules Data Aware Controls Programming with Data Providers
TDataSet
The Origins Paradox, the Paradox Engine, ODAPI, IDAPI, IDAPI, BDE
The Legacy A navigational interface in a largely set-based world
Things changed with Delphi 3
DelphiC++
BuilderData
GatewayVisualdBASE
Borland Database Engine (BDE)
Local TablesParadox, dBASE,
Access, FoxPro
Remote TablesOracle, Sybase,
MS SQL Server, ...
ODBC-readydatabases
SQL Links
TCP/IP, SPX/IPX, NetBEUI ODBC Driver
ODBC Socket
Session (default)
Database (default)
DataSets (Table,Query, StoredProc)
DataSource
Data Controls (DBGRid, etc.)
BDE
BDE Advantages
If you already have it installed and working for existing applications, new applications require little or no configuration to use it
Many legacy applications exist which use it Two or more applications written in Delphi can easily
share global aliases It has relatively good performance across a large
number of data types It provides access to installed ODBC drivers
BDE Limitations
In the typically deployment of BDE-based applications, a copy of the BDE must be installed and configured on each workstation (a network installation is possible, but requires manual registry configuration)
The BDE is somewhat inefficient, in that it stores as many as three copies of table metadata
When used with local tables such as Paradox tables, failure to correctly configure the BDE can produce periodic index corruption
If a new BDE application is incorrectly installed, existing BDE applications may fail to initialize properly
The BDE is available only for the Windows platform
Vendor Library
Database
Delphi’s dbExpress
Components
dbExpress Driver
dbExpress
SQLConnection
DataSource
ClientDataSet
DataSetProvider
SQLClientDataSet
Unidirectional DataSets
Data Aware Controls
dbExpress
dbExpress Advantages
Data-related operations in dbExpress tend to be faster than using other technologies
dbExpress-based applications can be deployed under both Windows and Linux environments
Applications designed to use dbExpress can more easily be ported to using DataSnap
dbExpress applications require fewer support files and can require far less configuration than BDE applications
dbExpress Limitations
dbExpress applications are generally more complicated than other types of Delphi database applications to program. In addition to requiring more components to access and edit data, dbExpress applications often require more lines of code than non-dbExpress applications
There are relatively few dbExpress drivers available
ActiveX
OLE DB Provider
Data
Delphi ADO Datasets
Microsoft Universal Data Access (MDAC)
Data Access Components
Plugable Layer
Data (database,spreadsheet, document, etc.)
TDataSet Descendants
DataSource
Data Aware Controls
TADOCommand
TADOConnection
ActiveX Data Objects
ADO Advantages
All Windows-based computers shipped in the past few years already have MDAC installed. As a result, most ADO-based applications require only the installation of the specific OLE DB provider, at most
ADO can be used from a wide range of development environments, including MS Access, VisualBasic, Delphi, Visual C++, to name of few
A wide range of OLE DB providers are available Applications that have been deployed as COM+ applications (formerly
referred to Microsoft Transaction Server components), can pool ADO connections, producing improved performance in environments that require large numbers of independent requests for data, such as Web server extensions
ADO Limitations
ADO is available only for the 32-bit Windows operating system Having MDAC installed and configured is not enough. In some cases, you
must also install and register an appropriate OLE DB provider Performance using ADO is largely reliant on the quality of the OLE DB
provider that you are using If you are using the OLE DB provider for ODBC, an appropriate ODBC
driver must also be installed and configured
MIDAS.DLLif MidasLib unit not used
Local FileXML or CDS
ClientDataSet
MyBase - ClientDataSet
DataSource
ClientDataSet
Data Aware Controls
MyBase
MyBase Advantages
MyBase applications have minimal installation requirements
The data can be stored in XML format, making it easy to access this data from outside of the application
Data can be loaded and saved without code. Simply point the client dataset's FileName property to a file that contains the proper XML or binary client dataset data, and it will take care of the rest. (It is better to explicity load and save using SaveToFile and LoadFromFile)
MyBase Limitations
Because the records in a client dataset are stored in-memory, the number of records that you can load is limited by the amount of real and virtual memory available on your machine
Large files may take a significant amount of time to load from a file into a client dataset. For example, 100,000 records may take 5 seconds or so to load into memory
MyBase applications are limited to single user applications. If you want to create a multiuser application, you must use one of the other available technologies
gds32.dll
InterBase
IBDatabase
InterBase Express
IBTransaction
IBDatabase
IBTransaction
IBSQL
IBTable, IBQuery, IBStoredProc, IBDataSet
DataSource
Data Aware Controls
InterBase Express
InterBase Express Advantages
InterBase Express provides access to InterBase without the BDE
Because InterBase Express components are designed specifically for InterBase, they include a number of specialized components that access and leverage InterBase features
Interbase Express components are available for both Delphi and Kylix, meaning that you can build applications that employ InterBase Express for machines running Linux
InterBase Express Limitations
InterBase Express works only with the InterBase database server
Database Server
DataSnap Server
DataSnap Clients DataSnap
Data Access Components
Database
Remote ConnectionComponent
Remote Data Modulewith DataSetProviders
DataSource
ClientDataSet
Data Aware Controls
Connection Components
SharedConnection
DataSetProvider
LocalConnection
ConnectionBroker
DataSnap
DataSnap Advantages
DataSnap client applications have few installation requirements
Business rules can be implemented on a server, permitting these rules to be updated independent of the individual client applications
They permit load balancing They can implement fail-over for high reliability They provide a reliable, distributed upgrade path to
dbExpress and MyBase applications The connection components support a variety of
internetworking protocols
DataSnap Limitations
While DataSnap offers additional flexibility over traditional client/server solutions, it requires more development. Specifically, in addition to writing the client application, you also need to write the application server
DataSnap applications require an additional license before they can be deployed. However, since Delphi 6, this license comes with the Enterprise and Architect editions of Delphi
DataSnap servers must also employ one of the other data access mechanisms. For example, the application server may use the BDE or ADO. As a result, DataSnap application developers must be familiar with at least two data access mechanisms (DataSnap plus at least one more)
Third-Party Data Access Components
Third-Party Data Controls Advantages
May support specialized features of the vendor’s database If designed with the TDataSet interface in mind, it may be easy to convert
from some other data access mechanism to the vendor’s data access mechanism
Third-party vendors are generally highly motivated to provide nearly bug-free components
Third-Party Data Controls Limitations
Typically support only one database Ties you to that vendors database
Data Modules
Non-visual container for non-visual components Permit sharing of objects Excellent classes for implementing custom components Are not always appropriate for data controls, especially
in the following situations Multi-instance forms Forms used for reports Unique data views
Data Aware Controls
Convenient and effective Permit you to build interfaces quickly Automatically respond to changes in the data Some developers have a bias against data aware
controls In response, they often create their own framework of
data awareness with custom controls
Using Providers in Database Applications
Independent layer for data access Decouples your user interface from the data access
mechanism Is a more generalized approach than data modules
Thank You !
Thank You !