ch11lev1sec1

   

ADO Versus BDE

There has always been a market for non-BDE components to be used with VCL programs in Delphi and C++Builder. There are a number of reasons for this. First, the BDE, rightly or wrongly, is perceived as being slow for some applications. Second, the memory and disk footprint of the BDE is thought by some to be larger than they prefer. Finally, even with installation programs such as Wise and InstallShield to reduce the complexity of installing the BDE, it has remained complex to ensure a safe BDE installation/upgrade, especially for releases of the BDE occurring between releases of the installer.

Prior to ADO, most component sets targeted either specific DBMS, such as dBase or InterBase, or database technologies, such as ODBC. Others implemented their own replacements for the BDE. However, they all had a problem ”their components had a unique interface that was not the same as that offered by the BDE-oriented components. This made it harder to change an application back to the BDE if that was desired. Unfortunately, the ADO components share this drawback.

ADO has several other drawbacks in comparison to the BDE. For one, it requires an explicit connection string that names a provider, server, and database, which makes it more difficult to provide easy retargeting of ADO components to other databases or DBMS without code changes. Secondly, unlike the BDE, SQL in ADO components cannot be used to heterogeneously join tables across databases within the same DBMS or across different DBMS.

One caution with the ADO components is that they do not eliminate the need to worry about revisions of the underlying libraries ”in this case, the ADO objects and the facilities needed by the database you are using (such as the Jet database engine required by Access).

Given all this, what are the advantages of the ADO components?

  • Much of their supporting software is delivered with the operating system, so you do not have to deploy it.

  • With driver development for the BDE somewhat slower than previous versions (though the BDE can use newer ODBC drivers, and those will continue to keep pace with DBMS development for some time), ADO can be your ticket to access unusual or advanced data technologies such as XML.

  • The ADO components can ease the transition from Microsoft tools, such as Visual C++ to C++Builder.

  • TADOQuery components are always editable without recourse to cached updates, UpdateSQL , or the complex conditions that allow a successful RequestLive . Note that a form of cached update (called batch update ) is available for ADO components.

  • The ADO components allow for SQL to be executed asynchronously and for monitoring the progress of commands through event handlers. This can also be used to provide the highly desirable progress meter to show how much of a query or command operation is complete.

  • Unlike the BDE components, it is fairly safe to halt a database program using Program Reset (this usually provokes an out of memory error from the BDE on the next run) ”however, when it is not safe, it usually takes your system down with it.

  • Finally, though you should conceal as much of the "ADOness" of the ADO components from your programs as you can, familiarity with the concepts of ADO can be useful for future employment or projects where management mandates the use of ADO.

Hedging Your Bets

It is a good idea to immediately create a thin layer between your system and the data components you choose to use. You can do this by creating a descendant or facade for each ADO component you intend to use, and never using the raw components themselves in your system. You can then change the ancestor of the component or the type of its contained component either directly or by conditional compilation, and all the uses of the component will, hopefully without change, use the new component set. If you must use specialized methods or properties of the underlying components, try first to hide them in methods or properties of a more general nature in the thin layer. If that cannot be done for some reason, bracket them with #ifdef , #else , or #endif commands keyed on a #define that identifies the underlying components in use.

Copying Records and Datasets

Unfortunately, TBatchMove will not work with the ADO components. You will have to write your own generic mover to perform copies with these components. Consider a thin layer class to replace TBatchMove .


   
Top


C++ Builder Developers Guide
C++Builder 5 Developers Guide
ISBN: 0672319721
EAN: 2147483647
Year: 2002
Pages: 253

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net