Migrate Your BDE Applications to Linux with dbExpress (cont'd)
Solution in Action: Create an App with Delphi/Windows and Kylix/Linux
As a final example, take the following steps to create an application that features a TDBGrid and TDBNavigator connecting to a local InterBase table with either Delphi on Windows or Kylix on Linux.
Using Delphi on Windows, the steps are as follows:
Drop a TDatabase component. Set its AliasName to IBLocal, and its DatabaseName to IBL.
Drop a TTable component. Set its DatabaseName property to IBL (which points to the Database component).
Select a TableName (like CUSTOMER). This will pop-up the Database Login dialog with username SYSDBA. The password is "masterkey".
Drop a TDataSource component. Set its DataSet property to the Table component.
Drop a TDBNavigator component. Set its DataSource property to the DataSource component.
Drop a TDBGrid component. Set its DataSource property to the DataSource component.
Set the Table.Active property to True to see live data at design-time.
Using Kylix on Linux, the steps are as follows:
Drop a TSQLConnection component. Select IBLocal as value for its ConnectionName property.
Drop a TSQLClientDataSet component (see Figure 4). Set its DBConnection property to the SQLConnection component and set CommandType to ctTable (we want to select a tablename).
Figure 4.TSQLClientDataSet (Click to enlarge)
Use the CommandText property to select a TableName (like CUSTOMER).
Drop a TDataSource component. Set its DataSet property to the (SQL)ClientDataSet component.
Drop a TDBNavigator component. Set its DataSource property to the DataSource component.
Drop a TDBGrid component. Set its DataSource property to the DataSource component.
Set the Table.Active property to True to see live data at design-time.
Steps 2 and 3 can be replaced with the following:
2. Drop a TSQLTable component (see Figure 5). Set its SQLConnection property to the SQLConnection component.
Figure 5.TSQLTable, TDataSetProvider, and TClientDataSet (Click to enlarge)
3a. Select a TableName (like CUSTOMER).
3b. Drop a TDataSetProvider component. Set its DataSet property to the SQLTable component.
3c. Drop a TClientDataSet component. Set its ProviderName property to the DataSetProvider component.
Note that in all cases the InterBase login dialog needs sysdba as the username and masterkey as the "secret" password.
Bob Swart (aka Dr.Bob) is a Delphi trainer and consultant who has spoken at the Borland Developer Conferences since 1993. As a freelance technical author, he has written chapters for The Revolutionary Guide to Delphi 2 (WROX), Delphi 4 Unleashed, C++ Builder 4 Unleashed, C++ Builder 5 Developer's Guide, and the upcoming Kylix Developer's Guide and Delphi 6 Developer's Guide (SAMS). He can be reached at drbob@chello.nl.
The Borland Database Engine (BDE) runs only on Windows, so Delphi applications that use it are not portable to Linux.
Move your application from the BDE to dbExpress, the new cross-platform, data access layer found in Kylix and future versions of Delphi, by replacing BDE data access components with corresponding dbExpress components and converting your data.
Find Out More
Get the source code for this Solution!
Do you expect dbExpress to replace the Borland Database Engine? Delphi 6 has been rumoured to include support for both the BDE and dbExpress. But will your new Delphi 6 projects be using BDE or dbExpress? Let us know in the database development discussion groups!