Click here to Skip to main content
13,739,613 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 21 Apr 2013
Licenced CPOL

.NET Reporting Tool Tutorial - 2

, 21 Apr 2013
Rate this:
Please Sign up or sign in to vote.
Second tutorial for loading data through code - Sqlite


This is the second tutorial for ReportMax free reporting tool for .NET developers ( As a pre-requisite, you need to read Tutorial 1. This new tutorial shows the developer how to connect to virtually any data source (in this example Sqlite) by code and without using Ole DB Providers.


If you have your own method of accessing a database, or if you do not have access to an Ole Db provider for that data source, or if you wish to access a custom data source (i.e. XML file), then you need to override SetDataSource event and write your own code to read from the database and bind it to the report. In this example, I will show how to connect to a Sqlite database using System.Data.Sqlite.dll and fill out the data set for the report to read from.

Using the Code

You will need ReportMax version 2.3. Please make sure this is the version you have even if you have downloaded it yesterday. It is under active development and gets updated frequently.

Report Designer

  1. Follow the steps to create the report in case you have not done so in Tutorial 1.
  2. Make sure the ConnectionString and SQL properties are blank.
  3. Make sure the ReportFile property is set to the correct MainReport.rpm path under the sample.

Report Viewer

  1. Add a reference to System.Data.Sqlite.dll from the sample folder. Since this is a version 2.0 DLL, you need to enable mixed assembly mode. Create or open the SqliteReportMaxSample.exe.config and paste the following code. Place this file where the executable is located:
    <?xml version="1.0" encoding="utf-8" ?>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
    <generatePublisherEvidence enabled="false" />
  2. Click on the ReportMaxViewer control on the Form designer. Click the Events in the Properties Window. Double click Report_SetDataSource Event. An event handler will be created and the focus will be moved to the code editor.
  3. Write the following statement at the top of the file:
    using System.Data.Sqlite;
  4. Paste the following code inside SetDataSource event handler:
    dataset = new DataSet();
    string connString = string.Format("Data Source={0};Version=3;", "..\\..\\Cities.db");
    SQLiteConnection con = new SQLiteConnection(connString);
    string sql = "SELECT Code, CountryName, CityName, City.Population FROM Country, 
    City WHERE Country.Code = City.Country ORDER BY CountryName;";
    SQLiteDataAdapter da = new SQLiteDataAdapter(sql, con);
  5. Run the application. You should see the report.

Points of Interest

The sample project is provided with this tip.


  • Initial release


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) CppMax
Canada Canada
Check out our light-weight, easy to use and powerful Microsoft .net reporting tool

You may also be interested in...


Comments and Discussions

QuestionAdding a second page Pin
23-Mar-15 7:31
member23-Mar-15 7:31 
Questionassign parameter value to a field in the report Pin
5-Mar-15 11:24
member5-Mar-15 11:24 
QuestionSetDataSource not binding to the rpm file Pin
5-Mar-15 4:43
member5-Mar-15 4:43 
AnswerRe: SetDataSource not binding to the rpm file Pin
emadns5-Mar-15 4:49
memberemadns5-Mar-15 4:49 
GeneralRe: SetDataSource not binding to the rpm file Pin
5-Mar-15 5:00
member5-Mar-15 5:00 
GeneralRe: SetDataSource not binding to the rpm file Pin
5-Mar-15 5:07
member5-Mar-15 5:07 
GeneralRe: SetDataSource not binding to the rpm file Pin
emadns5-Mar-15 5:19
memberemadns5-Mar-15 5:19 
GeneralRe: SetDataSource not binding to the rpm file Pin
5-Mar-15 6:23
member5-Mar-15 6:23 
GeneralRe: SetDataSource not binding to the rpm file Pin
5-Mar-15 6:51
member5-Mar-15 6:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.180920.1 | Last Updated 21 Apr 2013
Article Copyright 2013 by emadns
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid