In the previous tutorial, we covered how to connect to the MySQL database. This time we’ll look at how to connect to a PostgreSQL database from a FastReport.Net report.

FastReport provides a report designer plug-in that allows you to connect to Postgres. The core of this plug-in is the npSQL.dll library. But let’s go through the process in order.

First, we’ll look at connecting to the database using the FastReport plug-in. Then, I’ll demonstrate using the usual ODBC connector.

The first method:

Open explorer – Program Files (x86) \ FastReports \ FastReport.Net \ Extras \ Connections \ fastreport.postgres \ FastReport. Postgres. SLNS. Detected From this we will create the fastreport.postgres.dll library, which we will use as a report designer plug-in. The nPGSQL.dll library is required to generate this project. The NPGSQL installer can be downloaded here: github.com/npgsql/npgs… .

Once the connector is installed, the library can be found in the GAC.

Next we will build the fastreport.postgres.dll library that will be used as a report designer plug-in.

Open report Designer. In the File menu, open options. On the Plug-ins TAB, add the previously built library:

Restart the report Designer.

Now you can start creating a report. Let’s add a new data source. In the wizard, select New Connection… In connection Settings, select connection type: Postgres Connection.

We set the connection Settings for the DBMS. Click OK. In the Create Data Source wizard, click Next. And select the form you want:

Now consider the second approach. To do this, we need an ODBC connector, which you can download here: odbc.postgresql.org/.

Install the ODBC driver and continue to create the report. In report Designer, we add a new data source. In the New Data Source wizard, select New Connection… .

In connection string Settings, select connection type: ODBC connection.

In the Data Sources section, select Use Connection Strings. Then use theButton to open the connection string generator.

In the window that appears, we press “New…” Button:

Select the PostgreSQL ODBC driver:

Click Next. Specify the name of the connection:

Click Next. Now go to connection Settings:

Click OK. Then click OK again. We then return to the data source creation wizard. Click the next button to continue selecting the form:

That’s it. We have introduced two ways to join data in a report. Note that if you take the first approach, it will be more convenient to use the PostgreSQL database in subsequent reports. Also, it is faster than connecting through the ODBC connector.


Product introduction | download the trial | | | online customer service, contact Elyn preferential activities

 

Recommended reading
  • How do I display the estimated number of records on the report page
  • How to place multiple reports on a web page
  • How do I use reports when developing MVC applications
  • How to print reports quickly in MVC
  • 2016 Fastreport.Net tutorial
  • Fastreport.Net User manual
  • FastReport.Net v2018.1 update has been released! (With download)






www.fastreportcn.com/



www.fastreportcn.com/post/1960.h…