Posted by webmaster Guido
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); begin Movies.LoadFromFile(ExtractFileDir(Application.ExeName) + '\Movies.xml'); Movies.Open; end;
4.3. Delete the TTable component.
4.4. Rename ClientDataSet1 to Movies.
4.5. Set the property DataSet of DataSource1 to Movies.
We have a tutorial on using ClientDataSet with Delphi Starter.