RegisterData + DesignReport

OlaOla
edited December 2016 in FastReport .NET
I'm evaluating Fast report compared to other report engings for our .Net Web Project. I have downloaded the Trial and play around with, but I have some problem and the documentation is not so helpful.

I do my tests in Webforms

1) RegisterData
I have made a small report in the Windows designer. From my webforms i try to open that whit a different dataset (limited Query) but a cant get it working. My code:
wrote:
System.Data.DataSet dataSet = db.ExecDataSet("select Name, InternalId from DocumentType where property=25", "", null, null);

webReport.Report.RegisterData(dataSet, "DocumentType");
string report_path = GetReportPath();
webReport.Report.Load(GetReportPath() + "DocTypeListWithDs.frx");
But it runs with the data I have used in design of the report so it ignore my RegisterData command. What am I doing wrong?


2) DesignReport
I try to use the designer but the samples is only in MVC and i try to use it in WebForms. My code
wrote:
webReport.DesignReport = true;
webReport.ID = "TEST";
webReport.DesignScriptCode = false;
webReport.DesignerPath = "~/WebReportDesigner/index.html";
What I'm i supposed to write for DesignerPath ?
Or is the designer not avalible in the Trial version?

Comments

  • edited 6:02PM
    (1) RegisterData
    You mixed datasource in designer with datasource from code.

    open DocTypeListWithDs.frx with notepad, find the connection string, remove it.

    make sure the dictionary node in frx file, for example (adjust column name to your data structure) :
      <Dictionary>
        <TableDataSource Name="DocumentType" ReferenceName="DocumentType">
          <Column Name="CustomerID" DataType="System.String"/>
          <Column Name="CompanyName" DataType="System.String"/>
          <Column Name="ContactName" DataType="System.String"/>
          <Column Name="ContactTitle" DataType="System.String"/>
          <Column Name="Address" DataType="System.String"/>
          <Column Name="City" DataType="System.String"/>
          <Column Name="Region" DataType="System.String"/>
          <Column Name="PostalCode" DataType="System.String"/>
          <Column Name="Country" DataType="System.String"/>
          <Column Name="Phone" DataType="System.String"/>
          <Column Name="Fax" DataType="System.String"/>
        </TableDataSource>
      </Dictionary>
    


    (2) DesignReport
    you're right.

    This distribution contains the following files (not available in the Trial version) :
    fonts - fonts of report designer interface (http://fontawesome.io/license/)
    images - image files of report designer interface
    locales\*.js - Localization files
    scripts\
    config-data.js
    main.js
    vendors.js - report designer runtime files
    styles - files of markup styles
    index.html - report designer runtime file

  • OlaOla
    edited 6:02PM
    Thanks for your answer, but i doesn't work.
    * I have removed the connectionstring
    * I have checked that the dictonary in the reportfile correspond to my dataset
    But when i run i get error:
    DocumentType: The table is not connected to data. Register data by using RegisterData method
    (The error is for som ereason i Swedish so I have translated it)

    And my only code is
                webReport.ReportFile = GetReportPath() + "DocTypeListWithDs.frx";
                webReport.Report.RegisterData(dataSet, "DocumentType");
    

    And my report is very small, here is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <Report ScriptLanguage="CSharp" ReportInfo.Created="12/05/2016 13:29:36" ReportInfo.Modified="12/05/2016 19:06:58" ReportInfo.CreatorVersion="2016.4.31.0">
      <Dictionary>
          <TableDataSource Name="DocumentType" ReferenceName="DocumentType">
            <Column Name="Id" DataType="System.Int32"/>
            <Column Name="Name" DataType="System.String"/>
            <Column Name="InternalId" DataType="System.Int32"/>
            <Column Name="AutoSignDays" DataType="System.Int16"/>
            <Column Name="Property" DataType="System.Int32"/>
            <Column Name="PrintForm" DataType="System.String"/>
          </TableDataSource>
      </Dictionary>
      <ReportPage Name="Page1">
        <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8">
          <TextObject Name="Text1" Left="9.45" Top="9.45" Width="321.3" Height="18.9" Text="Testrapport i FastReport" Font="Arial, 12pt, style=Bold"/>
        </ReportTitleBand>
        <PageHeaderBand Name="PageHeader1" Top="41.8" Width="718.2" Height="28.35">
          <TextObject Name="Text4" Left="9.45" Top="9.45" Width="94.5" Height="18.9" Text="Name"/>
        </PageHeaderBand>
        <DataBand Name="Data1" Top="74.15" Width="718.2" Height="37.8" DataSource="DocumentType">
          <TextObject Name="Text3" Left="9.45" Top="9.45" Width="217.35" Height="18.9" Text="[DocumentType.Name]"/>
          <TextObject Name="Text2" Left="236.25" Top="9.45" Width="207.9" Height="18.9" Text="[DocumentType.InternalId]"/>
        </DataBand>
        <PageFooterBand Name="PageFooter1" Top="115.95" Width="718.2" Height="18.9"/>
      </ReportPage>
    </Report>
    
  • edited 6:02PM
    dataset is a container, contains one or more datatable, make it simple, get data from database and put into datatable.

    in your frx file : <TableDataSource Name="DocumentType" ReferenceName="DocumentType">
    TableDataSource with referencename = "DocumentType", it means referring to datatable with a name = DocumentType

    if you use dataset :
    <TableDataSource Name="DocumentType" ReferenceName="Data.DocumentType">

    Take a look at fastreport demo folder, there is a demo for "data from dataset", look like this:
         private void CreateDataSet()
        {
          // create simple dataset with one table
          FDataSet = new DataSet();
    
          DataTable table = new DataTable();
          table.TableName = "Employees";
          FDataSet.Tables.Add(table);
    
          table.Columns.Add("ID", typeof(int));
          table.Columns.Add("Name", typeof(string));
    
          table.Rows.Add(1, "Andrew Fuller");
          table.Rows.Add(2, "Nancy Davolio");
          table.Rows.Add(3, "Margaret Peacock");
        }
    
      <Dictionary>
        <TableDataSource Name="Employees" ReferenceName="Data.Employees" DataType="System.Int32" Enabled="true">
          <Column Name="ID" DataType="System.Int32"/>
          <Column Name="Name" DataType="System.String"/>
        </TableDataSource>
      </Dictionary>
    
  • OlaOla
    edited 6:02PM
    Thanks again for your answer, now it works. The solution is (for other potential readers...):
                System.Data.DataSet dataSet = db.ExecDataSet("select Id, Name, InternalId, AutoSignDays, Property, PrintForm from DocumentType where property=25", "", null, null); <=My own db reader
                dataSet.Tables[0].TableName = "DocumentType"; <=Name the datatable in the datatset to the same as you use in the report
    
                //webReport.Report.Load(GetReportPath() + "report.frx");   <=Load doesn't work 
                webReport.ReportFile = GetReportPath() + "DocTypeListWithDs.frx";  <= Must use Reportfile popertyn
                webReport.Report.RegisterData(dataSet);
    

    I have used FastReport before in my Delphi "era" and i really like it specially the good scripting capability. BUT i must say that the documentation and the samples really need an update, in my evulation of reporting products this is a drawback.
    I will also evaluate Stimulsoft Reports, at a fast glance the scripting possibility is less in this product and the documentation is also not up to date.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.