FireDAC.DBX2FDMigration Demo Sample

From RAD Studio Code Examples
Jump to: navigation, search

This page provides step-by-step instructions on how to migrate the Delphi demo application (MeetingOrganizer) to FireDAC.

For more information about migration from dbExpress to FireDAC, see Migrating dbExpress Applications to FireDAC.

Location

You can find the DBX2FDMigration project at:

Description

This sample project demonstrates how to migrate the project MeetingOrganizer from dbExpress to FireDAC using the reFind.exe tool.

How to Use the Sample

To use this sample project

  1. Run the migrate.bat utility.
  2. Create the new FireDAC connection definition.
  3. Add some additional components to your application form.
  4. Set up the FireDAC connection parameters.
  5. Run this demo application.

The following sections detail the steps of this procedure.

Run Migrate.bat Utility

The migrate.bat utility is located in the C:\Users\Public\Documents\Embarcadero\Studio\\Samples\Object Pascal\Database\FireDAC\Tool\reFind\DBX2FDMigration\Demo folder.

The migrate.bat utility creates a new subdirectory FireDAC_MeetingOrg under Forms, and copies the source files of your dbExpress application to the FireDAC_MeetingOrg folder. It keeps the original source files.

The utility runs the RAD Studio reFind tool in order to replace the dbExpress terms of the application with their FireDAC counterparts.

Example of reFind.exe usage:

reFind.exe FireDAC_MeetingOrg\*.pas FireDAC_MeetingOrg\*.dfm FireDAC_MeetingOrg\*.fmx /X:..\..\FireDAC_Migrate_DBX.txt

You can find the "reFind.exe" utility in "C:\Program Files (x86)\Embarcadero\Studio\\bin\reFind.exe".

To run Migrate.bat:

  1. Go to C:\Users\Public\Documents\Embarcadero\Studio\\Samples\Object Pascal\Database\FireDAC\Tool\reFind\DBX2FDMigration\Demo folder.
  2. Double-click the migration.bat application to start the migration process.

Creating the new FireDAC Connection Definition

  1. Open the project MeetingOrganizer.dproj located at C:\Users\Public\Documents\Embarcadero\Studio\\Samples\Object Pascal\Database\FireDAC\Tool\reFind\DBX2FDMigration\Demo\Forms\FireDAC_MeetingOrg
  2. Create a FireDAC connection definition using the FireDAC Explorer.
    1. Go to Tools > FireDAC Explorer.SYSDBA
    2. In the FireDAC Explorer tool, go to File > New > Connection Definition.
    3. Setup the connection definition parameters.

This is the simplest connection definition for the MeetingOrganizer application:

 [MO]
 Database=C:\Users\Public\Documents\Embarcadero\Studio\16.0\Samples\Object Pascal\Database\FireDAC\Tool\reFind\DBX2FDMigration\Demo\Database\MEETINGORGANIZER.GDB
 User_Name=SYSDBA
 Server=127.0.0.1
 DriverID=IB
 Password=masterkey

You can find the configuration file in C:\Users\Public\Documents\Embarcadero\Studio\FireDAC\FDConnectionDefs.ini

Adding some Components to Your Application Form

You need to add the following components to your application form:

Setting Up the FireDAC Connection Parameters

  1. In the Structure view, select FDConnection1.
  2. In the Object Inspector, specify the following parameters:
    1. Fill the ConnectionDefName property with the name of the connection defined using the FireDAC Explorer.
    2. Use the Params property to define the path to the database.

In the Code Editor, comment the part that is pointing to the dbxconnections.ini file:

procedure TMainDM.SQLConnectionBeforeConnect(Sender: TObject);
begin
//  SQLConnection.LoadParamsFromIniFile
//    (IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName)) +
//    'dbxconnections.ini');
end;

Running This Demo Application

  1. Press F9 or choose Run > Run.
  2. When prompted, type in the User Login and the Password: borland, borland.

See Also