Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Feature Tour

Christoph Wille edited this page Apr 7, 2014 · 11 revisions

In order to get the samples running without any difficulty you should read how to setup the sample environment.

The SharpDevelop Reports for .NET feature tour will cover the following topics:

1 - Creating Reports using the Pull Data Model

  1. First, please click "File / New" then select "Sharp Develop Reports" and click the "Create" button. New Report

  2. This brings up the SharpDevelop Reports Wizard where you can set the Report Name, the Report File Name, the Report Path and select the Report Model. Please keep "Pull Data" selected, then click the "Next" button:

Basic Report settings

  1. The next page allows you to define a database connection by right clicking "database connections" and selecting "Add connection"

Database Connection

  1. In the upcoming Data Link Properties dialog please select "SQL Native Client" and click "Next":

Database Connection

  1. In the Connection dialog please fill in the values as shown below and click "OK":

Database Connection

  1. Your SharpDevelop Reports wizard now shows the database connection and you can display the elements of the selected datasource:

Database Details

  1. Now please drag and drop the table "Categories" to the Command Text window. This will autogenerate the SELECT statement:

Auto generated SQL statement

  1. The next step in the wizard shows you the result set for your SELECT statement:

Result set for SELECT statement

  1. When clicking the "Finish" button now, your report will be generated and shown in the report designer:

Report in Report Designer

  1. When clicking the "Preview" tab you can preview the rendered version of your report: Report Preview

  2. And last but not least, when you click the "Report Viewer" tab you can print or export your report to a PDF file:

Report Preview

2 - Creating Reports using the Push Data Model

  1. To create a Push Data Model based Report, please repeat the steps 1 to 8 of "Creating Reports using the Pull Data Model". Instead of clicking "Next", now please right click you result set and select "Save Result (Schema only)" and enter a file name for your .xsd file:

Saving the .xsd file

  1. Now please create another Report, but instead of choosing "Pull Model" in step 1 of your wizard, please choose "Push Model" and click "Next". Step 2 of your wizard now allows you to select your previously created .xsd file and check which fields should be databound to your report:

Loading the .xsd file

  1. After clicking the "Finish" button, your report will be shown in the report designer:

Report Designer

3 - Creating Reports using Pull Data Model with Stored Procedures

  1. Please repeat step 1 to 6 from "Creating Reports using the Pull Data Model".

  2. Instead of dragging a table to the Command Text window now please drag the "CustOrdersDetails" Stored Procedure to the Command Text windows and click "Next":

Stored Procedure in SDR

  1. In the ParameterDialog please enter the value for the detected Parameters for the Stored Procedure and click "OK":

Stored Procedure in SDR

  1. The Query Result window now shows a preview of the selected data:

Stored Procedure in SDR

  1. After clicking the "Finish" button the report is displayed in the Report Designer:

Stored Procedure in SDR

4 - Creating Reports using Stored Procedures with Parameters at runtime

  1. Now please create a new Windows Application in your preferred .NET IDE and add a reference to the ICSharpCode.Reports.Core which is in the \bin\AddIn folder. Also please add a reference to System.Configuration.dll which is installed in the GAC.

  2. Define a connection string named "NorthwindConnection" which contains the connection string to your Northwind database:

     connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True;" providerName="System.Data.SqlClient" 
    
  3. Now, please add these additional usings:

     using System.Configuration;
     using System.Data.Common;
     using ICSharpCode.Reports.Core;
     using ICSharpCode.Reports.Core.Exporter;
    
  4. Paste the following code snippet into your application's code and correct the reportPath according to your path:

     ReportEngine engine = new ReportEngine();
     ReportParameters pm = new ReportParameters();
     
     ConnectionStringSettings css = System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnection"];
     DbProviderFactory factory = DbProviderFactories.GetFactory(css.ProviderName);
     DbConnection conn = factory.CreateConnection();
     
     string reportPath = @"C:\Users\AZeitler\Documents\SharpDevelopReports\Report1.srd";
     
     ReportModel reportModel = ReportEngine.LoadReportModel(reportPath);
    
     PageBuilder pageBuilder = engine.CreatePageBuilder(reportModel);
     pageBuilder.BuildExportList();
     
     pm.ConnectionObject = ConnectionObject.CreateInstance(conn);
     
     pm.SqlParameters.Clear();
     pm.SqlParameters.Add(new SqlParameter("OrderID", System.Data.DbType.Int32, 10480));
     
     engine.PreviewStandardReport(reportPath, pm);
    
  5. Please build and run your application. This should start up the Report Viewer from within your .NET Application with a preview of your previously created report:

Report Viewer