370 likes | 611 Views
Developing Win32 Database Applications with Delphi Cary 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
E N D
Developing Win32 Database Applications with DelphiCary JensenJensen 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
Delphi C++ Builder Data Gateway Visual dBASE Borland Database Engine (BDE) Local Tables Paradox, dBASE, Access, FoxPro Remote Tables Oracle, Sybase, MS SQL Server, ... ODBC-ready databases SQL Links ODBC Socket TCP/IP, SPX/IPX, NetBEUI ODBC Driver
Session (default) BDE Database (default) DataSets (Table, Query, StoredProc) DataSource Data Controls (DBGRid, etc.)
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
dbExpress Delphi’s dbExpress Components dbExpress Driver Vendor Library Database
dbExpress SQLConnection Unidirectional DataSets DataSetProvider ClientDataSet SQLClientDataSet DataSource Data Aware Controls
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
Microsoft Universal Data Access (MDAC) Delphi ADO Datasets ActiveX Data Access Components OLE DB Provider Plugable Layer Data (database,spreadsheet, document, etc.) Data
ActiveX Data Objects TADOConnection TADOCommand TDataSet Descendants DataSource Data Aware Controls
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
MyBase - ClientDataSet ClientDataSet MIDAS.DLL if MidasLib unit not used Local FileXML or CDS
MyBase ClientDataSet DataSource Data Aware Controls
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
InterBase Express IBDatabase gds32.dll InterBase
InterBase Express IBTransaction IBDatabase IBTransaction IBSQL IBTable, IBQuery, IBStoredProc, IBDataSet DataSource Data Aware Controls
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
DataSnap DataSnap Clients DataSnap Server Database Server
Remote Connection Component Remote Data Module with DataSetProviders Data Access Components Database
DataSnap DataSetProvider Connection Components LocalConnection SharedConnection ConnectionBroker ClientDataSet DataSource Data Aware Controls
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 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