logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to quickly use connectors to databases from the Nuget repository
  • FastCube - High-Speed OLAP Cube Engine and Pivot Grid

    February 29, 2020

    It is difficult to imagine data analysis without OLAP (On-Line Analytical Processing) technology. Although there

    read more
  • How to programmatically set the default email client settings for sending emails from FastReport.NET

    February 12, 2021

    Like many other report generators, FastReport .NET allows you to send a report via email

    read more
  • Creating and outputting ITF-14 barcodes in .NET applications

    February 25, 2021

    ITF-14 (Interleaved Two of Five) is a two-band numeric code, otherwise known as a high-density

    read more
  • Create a new report with code VB.NET

    September 17, 2020

    Speaking of the .Net framework, we usually imagine the #C programming language. Simply because the

    read more
  • Report generators family FastReport brief review

    March 23, 2020

    Without reporting it is impossible to carry on business in any sphere of life. Bureaucracy

    read more

How to quickly use connectors to databases from the Nuget repository

May 28, 2018

FastReport.Net has been supplying plugins for a long time - connectors to various databases. These plugins allow you to add connectors to the report designer to connect to the required database. The purpose of creating these plug-in connectors is to simplify the process of connecting to a data source.

However, there is one inconvenience in using such plug-ins - they must first be compiled. And for this you must first download third-party libraries from the developer's database site. But, once you have compiled the plug-in, you can use it for as long as you like.

FastReport now distributes these connectors in the form of libraries through the Nuget package manager. This is true both for the .Net Framework 4 application and for ASP .Net Core. Now we are spared the need to compile plugins with third-party libraries, for which many thanks to the developers of FastReport.

Let's talk about the peculiarities of using these libraries. To create a report, you need to call the designer. With plugins, you would use a separate Report Designer program, which is convenient. But with the installed connector libraries, you'll need to call a designer from your application to use these connectors in your report.

If for WinForms applications to call the report designer from the code is a trifle, then in .Net Core applications it is impossible. Of course, there is Online Designer for web development of reports, but this is a completely different story. Therefore, you must first create a WinForms application, install the required connector into it and call the report designer. Or you can use the already compiled Designer.exe application that comes with FastReport, but in this case the list of supported DBMS will be limited (MS SQL is supported).

Let's now take a look at all this with an example. Create a test WinForms application and add FastReport.Net libraries to it. And also try to install connectors from the manager Nuget.

The figure shows that we have connectors to the databases: MsSql, MySql, Postgres, SQLite, Json, MongoDB, RavenDB.

Let's try to connect to the Json data source. Install the appropriate connector from Nuget.

On the form, add a button and the following code for it:

1
2
3
4
5
6
7
8
9
10
using FastReport;
using FastReport.Data;
using FastReport.Utils;
…
 private void button1_Click(object sender, EventArgs e)
 {
 new JsonAssemblyInitializer();
 Report report = new Report();
 report.Design();
 }

 In the first line of the button click event handler, we initialize the added JSON connector. Then create a report object and call the designer.

In the designer, we create a new data connection. And among the available connectors we see the JSON we added. Select it and set the path to the data file with the .json extension.

 

Create a report template and save it. Now, in the code for our button, you can replace the line:

1
report.Design();

 to:

1
2
report.Load(@"TestJsonConnection.frx");
report.Show();

 Here we specify the path to the report file that we created earlier and run the report for the show.

Thus, using the library-connector required from us only two actions - to install the library from Nuget, and to initialize it in the code.

However, not everything is so simple if it comes from ASP .Net Core application.

Firstly, we need to create a report. And for this we need to run the designer from the code. In web projects, this is impossible. I'll have to create a WinForms application, specifically to run the designer. Either install the plugin in a separate ReportDesigner and create reports in it.

Secondly, the program code is somewhat more complicated. In addition to initializing the connector library, you will need to specify a connection string, create tables, and add a connection to the report:

1
2
3
4
 JsonDataConnection conn = new JsonDataConnection();
 conn.ConnectionString = "Json=\"K:\\Documents\\nwind.json\"";
 conn.CreateAllTables();
 report.Dictionary.Connections.Add(conn);

 By labor, this is comparable with the use of third-party libraries for connecting to databases. So, in the case of .Net Core, not everything is so unambiguous. But in the .Net Framework 4 applications, the advantages over third-party libraries are obvious.

about product download buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Contact us

© 1998-2022 by Fast Reports Inc.

  • Privacy Policy