Typed Dataset DataSource for ActiveReports 7 & C1Report

ComponentOne provides two reporting tools namely ActiveReports 7 and C1Report . These components give developers and the end users similar flexibility to connect reports to various data sources. One data source that has been garnering a lot of attention has been the XSD or the Typed Dataset.aspx). This blog article sums up the steps that developers would need to connect C1Report and ActiveReports 7 to a Typed Dataset. The first step that is common to both the reporting components relates to Creating a Typed DataSet or the XSD file that needs to be used as a Datasource for the report. Now that you have Typed Dataset ready, let’s go through the steps on How to Connect ActiveReports 7 and C1 Report to a Typed Dataset (XSD)

Steps to Connect a Typed Dataset to ActiveReports

  1. Add a new Dataset control to the ActiveReport7 Report Designer in Visual Studio; this will open Add Reference Window.
  2. In the Add Reference Windows , add a reference to the existing XSD file. 4. Set the name of the DataSet created in previous step in DataSource property of Section Report.
  3. Set the DataMember property of the report. 7. Database fields should appear in the Bound fields of Report Explorer. Drag Bound Fields from the Report Explorer to the Report designer and design the Report accordingly.
  4. In the code behind of Section Report, create an instance of TableAdapter and then fill this Adapter with the required table from the DataSet.
 private void Report_ReportStart(object sender, EventArgs e)  
   NWINDDataSetTableAdapters.ProductsTableAdapter da = new XSD_dataSource.NWINDDataSetTableAdapters.ProductsTableAdapter();  

  1. Run the Report and View the Report in the ActiveReports Viewer

Steps to Connect a Typed Dataset to C1Report

  1. Open the C1ReportDesigner application and click the New Report button from the Reports tab to open the C1Report Wizard.
  2. Set the Data Provider to XML Database and assign the location of the XSD file to Connection String. This will result in the Data source Tab to be populated with Tables from the XSD file.
  3. Design your report accordingly and save the Report XML to a specified location. 5. Open Visual Studio and add the Report XML to your solution.
  4. Place a C1PrintPreviewControl on the Windows Form & repeat Steps 1 and 2 as described in the above section Steps to Connect a Typed Dataset to ActiveReports.
  5. Use code provided below to Load the Report XML and Set the Recordset Property of the C1Report to the Typed dataset referenced in Step 6 and view the report in C1PrintPreviewControl.

    public void LoadC1Reports()  
       // load report definition (before setting the data source)  
       c1Report1.Load(GetFilePath("Report.xml"), "Products Report");  
      // Set the XSD DataSource  
      c1Report1.DataSource.ConnectionString = GetFilePath("NWINDDataSet.xsd");  
      //  Fill the dataset  
      NWINDDataSetTableAdapters.ProductsTableAdapter da = new XSD_dataSource.NWINDDataSetTableAdapters.ProductsTableAdapter();  
      c1Report1.DataSource.Recordset = nwindDataSet1.Products;  
      c1PrintPreviewControl1.Document = c1Report1;  

    C1Report Output

Download the attached samples for complete implementation. Download C# Sample Download VB.NET Sample


GrapeCity Developer Tools
comments powered by Disqus