Migrating a Database application: no BDE!

Posted by webmaster Guido on January 15, 2008

In Reply to Re: Database applications without BDE posted by webmaster Guido on January 10, 2008

: Migrating (rewriting) desktop database applications for operation without the BDE is easy:

: 1. Replace all combinations of TTable/local-database-file (such as Paradox, DBase,...) with combinations of TClientDataSet/XML-file.
: 2. Convert your local database files (Paradox, dBase,...) to XML files.
: 3. If your old program uses indexes, then you've got to add some source code for indexing the ClientDataSet(s).
: 4. Remove all DBE related stuff from your source code.

Here's an example for migrating a simple database program, removing the BDE dependancy.

A program named "Movies" has a form that contains a DBGrid. The DBGrid is connected to DataSource1, and DataSource1 is connected to a TTable component named "Movies". Movies points to the dBase file Movies.dbf, located in the same directory as the project files.

Start by making a backup copy of your old application -- zip it or copy it or whatever-- don't blame me if the migration doesn't work and you lost your data ;)


1. Add a TClientDataSet component to the form. Delphi will name it ClientDataSet1.

2.1. Right click on ClientDataSet1, and select Assign Local Data from the popup-menu that appears. Select "Movies" in the dialog that opens.

2.2. Right click again on ClientDataSet1 and select Save to MyBase XML table. Give it the name "Movies.xml". Attention: check that you select the correct directory in the dialog that appears!

3. The old program doesn't use table indexes, so we don't have to bother here.

4.1. Set the property Active of ClientDataSet1 to False.

4.2. In the OnCreate event handler for the form (if it doesn't exist yet, create an event handler) add the following code:

procedure TForm1.FormCreate(Sender: TObject);
  Movies.LoadFromFile(ExtractFileDir(Application.ExeName) + '\Movies.xml');

4.3. Delete the TTable component.

4.4. Rename ClientDataSet1 to Movies.

4.5. Set the property DataSet of DataSource1 to Movies.

We'll publish a tutorial on this shortly, stay tuned!

Related articles


Follow Ups