FireDAC.DBX2FDMigration Demo Sample

From RAD Studio Code Examples
Jump to: navigation, search

This example shows you step by step how to migrate to FireDAC the Delphi demo application (MeetingOrganizer).

For more information about the basics of migrating components, properties and code from dbExpress to FireDAC, please see Migrating dbExpress Applications to FireDAC.

Location

You can find the DBX2FDMigration project at:

Description

This demo demonstrates the migration of the project MeetingOrganizer from dbExpress to FireDAC using the reFind.exe tool.

How to Use the Sample

1.- Run Migrate.bat Utility

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

The migrate.bat utility creates a new subdirectory at Forms, called FireDAC_MeetingOrg, 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 at "C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\reFind.exe".

To run Migrate.bat:

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

2.- Setting FireDAC Connection Definition

  1. Open the project MeetingOrganizer.dproj located at C:\Users\Public\Documents\Embarcadero\Studio\18.0\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 at C:\Users\Public\Documents\Embarcadero\Studio\FireDAC\FDConnectionDefs.ini

3.- Preparing Your FireDAC Application for Run Time

You need to add a specific component to your application:

  1. Open UMainDM.dfm.
  2. Add a TFDGUIxWaitCursor component.

4.- Setting Up Connection Params

  1. On the UMainDM.dfm go to the code.
  2. Set up the TFDConnection component in the data module:
    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.

On the code, 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;
  1. Press F9 or choose Run > Run.
  2. Introduce the User Login and the Password: borland, borland.

See Also