ADS and Delphi


Delphi has been the development environment of choice for ADS developers for some time. While we anticipate that other languages, such as C#, will be the choice of a growing number of ADS developers due to the availability of the Advantage .NET Data Provider, Delphi will continue to be an excellent tool for working with ADS.

There are two primary reasons why ADS and Delphi go so well together. The first is the abundance of ADS features that are available through the Advantage TDataSet Descendant classes. Using these components, it is extremely easy to access, change, and manage your ADS data.

The second reason is that the data access model supported by the BDE (Borland Database Engine), and encapsulated in the TDataSet abstract class of the VCL (visual component library), fits beautifully with the navigational model that ADS’s ISAM architecture permits. This reason is actually closely related to the first. The ease with which Delphi developers can use ADS is a direct result of the nearly seamless way in which the TDataSet interface and the ADS API (application programming interface) interact.

But there is more. The ADS components that descend from TDataSet do much more than simply conform to much of the TDataSet interface. In addition, they also expose a large number of functions in the ACE API. For example, you can call AdsStmtSetTablePassword on an AdsQuery to submit a free table’s encryption password before attempting to query it. This method is not part of the TDataSet interface, but is exposed by this component to simplify your work with ADS without having to deal directly with ACE.

An interesting piece of evidence for this near perfect fit between ADS and Delphi is that the Advantage Data Architect is written in Delphi. In fact, when you install the Advantage Data Architect, the Delphi source files and packages that are used to build the Advantage Data Architect are included. Indeed, these Delphi units can be a fascinating source of ideas if you need to perform some task that is out of the ordinary.

Understanding the TDataSet Descendants

The name TDataSet descendant is actually something of a misnomer. While the TAdsTable, TAdsQuery, and TAdsStoredProc components do indeed descend from the TDataSet class, there are several other classes on the Advantage page of the Component Palette in Delphi that do not. These include the TAdsConnection, TAdsDictionary, and TAdsSettings classes. Nonetheless, these components, which are shown here, are generically referred to as TDataSet descendants.

That TAdsTable, TAdsQuery, and TAdsStoredProc all descend from TDataSet means that they share a common programming interface with all other standard Delphi data access components. This interface is largely navigational, although it also supports the entire range of set-based operations of Advantage SQL through the TAdsQuery class.

Because the TDataSet descendants share a common interface with other Delphi data access components, such as TTable, TSQLDataSet, TIBQuery, TClientDataSet, among others, converting an existing Delphi application to use ADS is pretty straightforward. In fact, now that Borland has officially deprecated the BDE, ADS is an almost unbeatable option when choosing an alternative data access mechanism, especially if your application already uses the navigational model.

The remainder of this chapter shows you how to access ADS using Delphi. This discussion is divided into three parts. The first part describes common basic tasks, such as connecting to ADS and accessing data. The second shows you how to leverage the navigational model with Delphi and ADS. The third part demonstrates several basic administrative tasks, such as creating tables and granting rights to them.

ON THE CD

The Delphi project Delphi_TDataSet.dpr can be found on this book’s CD-ROM (see Appendix B). This project was created using Delphi 7, but is compatible with Delphi versions 5 and later.

All of the examples presented here can be found in a Delphi project named Delphi_TDataSet. Figure 12-1 shows the main form of this project in Delphi.

click to expand
Figure 12-1: The Delphi_TDataSet project’s main form

A final comment about this project is in order. Many of the operations performed in this project make use of the AdsTable component, which is pretty common for Delphi applications. Many of these same operations can be performed using a SQL query executed through an AdsQuery. For examples of possible SQL alternatives, refer to Chapters 13–16.




Advantage Database Server. The Official Guide
Advantage Database Server: The Official Guide
ISBN: 0072230843
EAN: 2147483647
Year: 2002
Pages: 129

Similar book on Amazon

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