Migrating from Borland Database Engine (BDE)

   

The first step in moving your BDE applications to dbExpress consists of converting your data from a BDE format to a database format that can be used by dbExpress. The BDE supports dBASE, Paradox, and InterBase, and for dbExpress we have drivers for InterBase, among others. The one format that both share is InterBase, so if you want to migrate existing BDE applications that are not in InterBase format, you might consider moving the data to InterBase in the first place. This will solve half of your migration problem; the rest consists of replacing BDE components with corresponding dbExpress components .

The BDE components that you can migrate are TTable , TQuery , TstoredProc , and TDatabase . The TSession component is only relevant for BDE-specific applications, so it's not needed in a dbExpress application.

The equivalent of the BDE TDatabase component is the dbExpress TSQLConnection component. Both are used to make a connection to the actual database. TSQLConnection has a number of predefined connections that can be found in the drop-down list for the ConnectionName property, such as a DB2Connection, IBLocal, MySQLConnection , or OracleConnection . You can also right-click the TSQLConnection component and pick Edit Connections Properties to see the Connection Settings for the different Connection Names, like we did earlier in this chapter.

The dbExpress TSQLTable , TSQLQuery , and TSQLStoredProcedure will all use a TSQLConnection component to connect to the dbExpress database, just as the BDE TTable , TQuery , and TStoredProc components use a TDatabase component to connect to the BDE database.

The equivalent of the BDE TTable component is the dbExpress TSQLTable component. The main difference is the fact that the TSQLTable component returns a read-only and unidirectional dataset. This means that you can only navigate forward, to be used to walk through once. If you try to move backward, an exception will be raised.

The equivalent of the BDE TQuery component is the dbExpress TSQLQuery component. The main difference is the fact that the TSQLQuery component returns a read-only and unidirectional dataset (just like the difference between the BDE TTable and the dbExpress TSQLTable component).

A unidirectional dataset involves no caching or overhead. This is the main reason why dbExpress data access components are much faster than their BDE equivalents. On the other hand, dbExpress components such as TSQLTable and TSQLQuery turned out to be a bit harder to use on a visual form connecting to a TDBGrid or TDBNavigator component, therefore, we have to add an additional TDataSetProvider and TClientDataSet component.

The equivalent of the BDE TStoredProc component is the dbExpress TSQLStoredProcedure component. However, this is the place where you can possibly encounter a number of problems if you migrate a local BDE application to dbExpress because a stored procedure for use in one DBMS is likely to differ from a stored procedure for use in another DBMS. InterBase, which is supported by both the BDE and dbExpress (and runs on Windows as well as Linux) might be the exception again.

Now that we've mapped four basic BDE dataset components, we still have two dbExpress components left that can still play an important role while migrating BDE applicatons: the TSQLDataSet and TSQLClientDataSet . The TSQLDataSet component is capable of acting like a TSQLTable , TSQLQuery , or TSQLStoredProcedure component all in one, with the CommandType property as main discriminator (the value of CommandType determines how the value of the CommandText property is interpreted).

Finally, the TSQLClientDataSet component is the powerful combination of a TSQLDataSet , a TDataSetProvider , and a TClientDataSet component to produce a bidirectional caching dataset (remember that the TSQLTable , TSQLQuery , and TSQLStoredProcedure all return a unidirectional read-only dataset, so if you want to use them in a bidirectional way like the BDE datasets, you need to connect these three components to a TClientDataSet component via a TDataSetProvider componentor use the TSQLClientDataSet component instead).

Migration Example

As a final example, I will list the steps to create an application that features a TDBGrid and TDBNavigator connecting to a local InterBase table using the BDE first, and then dbExpress. If you compare the steps, you can also see what is needed to remove the BDE components and replace them with dbExpress components ( assuming you have migrated the database tables to a dbExpress compatible format as well).

Using BDE to Build an Application

Using the Borland Database Engine, the steps to build an application using the InterBase CUSTOMER table are as follows (assuming we have started a new project):

  1. Drop a TDatabase component; point its AliasName property to IBLocal , and its DatabaseName property to IBL (this is just the name that we will use in our application).

  2. Drop a TTable component, point its DatabaseName property to IBL (which points to the Database component from the previous step).

  3. Open the drop-down combo box for the TableName property and select the CUSTOMER table. This will pop-up the Database Login dialog with username sysdba . The password is masterkey .

  4. Drop a TDataSource component; point its DataSet property to the TTable component.

  5. Drop a TDBNavigator component; point its DataSource property to the TDataSource component.

  6. Drop a TDBGrid component; point its DataSource property to the TDataSource component.

  7. Set the Table, Active property to true to see the live data at design time.

Using dbExpress to Build an Application

Using dbExpress instead of the BDE, the steps to build an application using the InterBase CUSTOMER table are as follows (again starting with a new application):

  1. Drop a TSQLConnection component, and select IBLocal as the value for its ConnectionName property (edit the Connection Properties to make sure the Database points to a valid InterBase database).

  2. Drop a TSQLClientDataSet component, point its DBConnection property to the TSQLConnection component and set CommandType to ctTable (we want to select a tablename ).

  3. Open the drop-down combo box for the CommandText property and select the CUSTOMER table. This will pop-up the Database Login dialog with username sysdba . The password is masterkey .

  4. Drop a TDataSource component; point its DataSet property to the T(SQL)ClientDataSet component.

  5. Drop a TDBNavigator component; point its DataSource property to the TDataSource component.

  6. Drop a TDBGrid component; point its DataSource property to the TDataSource component.

  7. Set the (SQL)ClientDataSet, Active property to true to see the live data at design time.

The second and third steps can be replaced with the following four steps (replacing the TSQLClientDataSet with the TSQLDataSet , TDataSetProvider , and TClientDataSet combination):

  1. Drop a TSQLTable component; point its SQLConnection property to the TSQLConnection component.

  2. Select a TableName (such as CUSTOMER).

  3. Drop a TDataSetProvider component; point its DataSet property to the TSQLTable component.

  4. Drop a TClientDataSet component, point its ProviderName property to the TDataSetProvider component.


   
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