Configure PostgreSQL Server Connection for Software Installer

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

A connection to a PostgreSQL Server is required in order to execute scripts throughout your software installation process or if it is dependent on certain database content. In this tutorial, we will show you how to configure the proper settings in order to connect an installation package to the PostgreSQL Server.

This tutorial uses the predefined SQLConnectionDlg dialog and all the settings will be collected during install time and then passed to the installer. In order to do this public properties will be used.

1. Create project

Launch Advanced Installer, select Enterprise and press the [ Create Project ] button.

Start Page

2. Add SQL connection dialog

Dialogs Page Go to Dialogs Page and select FolderDlg dialog. Select “Add Dialog” toolbar option or “Add Dialog...” context menu option.

The Add Dialog dialog will appear. Select SQLConnectionDlg from the list and press "OK". The new dialog will be added in the chain after the FolderDlg dialog.

In the SQLConnectionDlg dialog select the "ODBC Resource" static text control and from the Properties pane located in the right side, set the Visible attribute to False.

Repeat the same procedure for the edit box control associated with "ODBC Resource".

3. Install PostgreSQL ODBC driver

In order to connect to the PostgreSQL Server a compatible ODBC driver is required. In this tutorial, we will assume the PostgreSQL ODBC driver is already installed on the developer machine.

TipThe PostgreSQL ODBC driver can be download, for free, from PostgreSQL website.

Once the PostgreSQL ODBC driver has been downloaded it can be set as a prerequisite package. This way the installer will check if the ODBC driver is installed on the target machine and if not, it will install it.

4. Create the SQL connection

Sql Navigate to SQL Databases Page, Database server and select “New SQL Connection -> Predefined SQL Connection” option from the toolbar or context menu.

NoteThis will change the installation type to "Per-machine only".

Rename the connection to something meaningful. Using the "SQL Connection" properties pane from the right side, write the following settings:

Parameter nameValue
Connection TypePostgreSQL Server
Connection ModeODBC Driver
ODBC DriverPostgreSQL (or the one installed on the machine)
Server[SERVER_PROP]
Port[PORT_PROP]
Username[USERNAME_PROP]
Use a property to set password[PASSWORD_PROP]
Database[DATABASE_PROP]

Since we are going to use this connection with PostgreSQL Server we will not use a property to set the "ODBC Driver" parameter and we will hard-code it instead.

PostgreSQL Server connection configuration

Project build Add all the necessary resources like files and folders to the project, build and run it.

5. Test the installation package’s connection with the PostgreSQL Server

It is wise to test if the package is correctly connecting to PostgreSQL Server before giving it to your customers.

Note The Test SQL Connection How To article shows the steps needed to take in order to test your SQL connection.

Once the installation package is running navigate to the "SQL Database" dialog and enter the following information:

  • Server
  • The name of the SQL Server. If the server is hosted on the local machine use localhost.
  • Port
  • The port used by the SQL Server. By default, Microsoft SQL Server uses the 5432 port.
  • Database
  • The name of the database to which the install package will connect to. By default, PostgreSQL uses template1 database.
  • Username
  • The username under which the connection will be initiated. By default, PostgreSQL Server comes with the postgres user.
  • Password
  • The password associated with the user. For the postgres user this password is set during the server installation.

Postgre Server connection settings

6. See also

Configure most common SQL connections