Database.ODBCPostgreSQL Sample

From Appmethod Code Examples
Jump to: navigation, search

This sample uses dbExpress and LiveBindings components to get data from an ODBC connection.

Note: To run this sample you need to have the ODBC PostgreSQL driver installed. The applications compiled as 32-bit require the 32-bit ODBC driver and the 64-bit applications require the 64-bit ODBC driver.


You can find the ODBCPostgreSQL sample project at:


This sample gets the data from an ODBC database.

You can post new records using the Insert button of the TBindNavigator component. Enter the Country and the Currency values into the TEdit fields and click the Post button. The data is accessed using components as: TSQLConnection, TSimpleDataSet, or TStringGrid.

How to Use the Sample

  1. Navigate to Start > Programs > Appmethod 1.14 > Samples > Object Pascal > Database > dbExpress > ODBCPostgreSQL and open Fmi_dbExpress_ODBC.dproj.
  2. Go to the Data Explorer.
  3. Right-click the OdbcConnection.
  4. Click the Modify option.
  5. In the Modify Connection window, set the Database, User name, and Password properties as you have provided them during the driver installation.
  6. Click the OK button.
  7. Right-click the OdbcConnection.
  8. Select the SQL Window.
  9. Copy and paste the script.sql content from the sample directory.
  10. Click the Execute SQL button.
  11. Click the TSQLConnection component from the project form.
  12. Set the Connected property to true.
  13. Click the TSimpleDataSet component.
  14. Set the Active property to true.
  15. Press F9 or choose Run > Run.


File Contains


Contains the base form.


The project itself.


TForm1 is the form of the application. This class contains objects as: TSQLConnection, TBindingsList, TStyleBook, TRectangle, or TShadowEffect.


  • Form1 has the StyleBook property set as StyleBook1. This causes the backgroundstyle or colorbuttonstyle of TStringGrid or TRectangle components to change.
  • Rectangle2 is the parent object of all the other visual components from the form.
  • BindScopeDB1 makes the necessary connections between country and currency fields and BindNavigator1, Edit1, Edit2, or StringGrid1 objects.


See Also