In order to show how it works, I created a FireMonkey project sample that connect to a PostgreSQL database.
As first step, you must install the PostgreSQL ODBC driver on the machine that will run the application. Second, applications compiled as 32-bit, requires the 32-bit ODBC driver, 64-bit applications will require the 64-bit ODBC driver.
Onde installed the driver, create and configure a User DSN or System DSN on the ODBC Data Source Administrator (odbcad32.exe):
Instructions for windows 64-bit
- For 32-bit applications use c:\Windows\SysWOW64\odbcad32.exe
- For 64-bit applications use o c:\Windows\system32\odbcad32.exe
Instructions for windows 32-bit
- Use c:\Windows\system32\odbcad32.exe
The next step is to create an dbExpress ODBC alias on Data Explorer, where the Database Name parameter is the name of the Data Source created earlier, in my example the Data Source is called PostgreSQL35W. The database, username and password was already defined in the Data Source, but you can override the username and password parameters through the SQLConnection.
Assuming you already know how to use the SQLConnection, DataSetProvider and ClientDataSet or SimpleDataSet ,and DataSource components, just connect all the components as you usually do. The SQLConnection will look like this:
object SQLConnection1: TSQLConnection ConnectionName = 'PostgreSQLOdbc' DriverName = 'ODBC' LoginPrompt = False Params.Strings = ( 'drivername=ODBC' 'Database=PostgreSQL35W') end
You can use the dbExpress framework when connected to a database through dbExpress ODBC driver. In XE2 the ODBC driver is compatible with Windows, we are evaluating the possibility to support this driver on Mac.
The figure below shows the FireMonkey application connected to PostgreSQL via dbExpress ODBC driver. Now you can connect to any other other database not supported natively by dbExpress.
Download the source code here.