Our own data provider for Report

HasithaHasitha Sri Lanka
edited 4:36AM in FastReport .NET
Hi,

We are developing a report designing solution for a client. We are looking at your report designing control also as a solution. Our client needs to customize the Data source of the FastReport dictionary. For an example we need to have a XXXDatasource instead of OLEDBDatasource or SqlDatasource.(Our own data provider) And we need to restrict end user to only use customized data source of ours. If we can encapsulate connection string and all other database related information in to this datasource that???s what we are looking for. We need our end users to write their own sql statements and design the report without selecting or editing database information.

And can we save the report in to database then load it back to the designer and then Edit existing sql statement ?

Greatly appreciate your swift response on this.

Thanks.

Hasitha.

Comments

  • edited 4:36AM
    Hello,

    You may use the application connection in the designer. To do this, set the Config.DesignerSettings.ApplicationConnection property to the instance of your connection object. In this case you will not be able to select another connection in the designer. Note that your connection must be supported by FastReport (standard supported connectors are - MS Sql, OleDB, Odbc, also available additional connectors such as Firebird, MySql, etc).

    To save/load a report to a DB, you may define own save/load dialogs. See the demo Demos\C#\CustomOpenSaveDialogs.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    I created a OleDb connection and set to ApplicationConnection as you mention above. My code looks as follows.

    DbConnection connection = new OleDbConnection("Provider=SQLNCLI10; Data Source=DEV36; Initial Catalog=WMS; Persist Security Info=False; User ID=WMSUSER; Password=123;");
    connection.Open();

    Config.DesignerSettings.ApplicationConnection = connection;

    designerControl.Report = fastReport;
    designerControl.RefreshLayout();

    But when I go to "Add Data Source", there are no any table appear in the popup. I tried with SqlConnection, it is working without any problem.

    Do you see anything missing in the code above.

    Thanks,

    Hasitha.
  • edited 4:36AM
    Hello,

    I have tried the same code, it works well. Probably something is wrong with the connection string.
    Note that you don't need to open the connection. FastReport actually uses the copy of the connection you provide.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    Thanks for the quick reply. I checked the connection string and its fine. Even I changed the provider from "SQLNCLI10" to "SQLOLEDB", still the problem is there. I tried with "Add Sql Query" in the Data wizard by constructing Select * From TableName. That way I could create a table. But, what I really need is to load all the table from the database to "Data Wizard".

    Is there any other way to do this?

    Thanks,

    Hasitha.

  • edited 4:36AM
    Could you send me a simple test project (with data) which demonstrates the error? I cannot reproduce it.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    Please find the sample project attached herewith.

    Thanks,

    Hasitha.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    Can anyone help me on this. Coz we need to do a demo for our client.

    Thanks,

    Hasitha.
  • edited 4:36AM
    Hello,

    Looks like the bug in our code. OleDBConnection is replaced by connector to MS Access. Will be fixed in the next daily build.
  • HasithaHasitha Sri Lanka
    edited February 2012
    Hi,

    Thanks for the reply. In our application we have a nhibernate connection and we are going to use this connection when we open a report. But the problem is "Config.DesignerSettings.ApplicationConnection" does not allow an open connection. Is there any workaround for this.

    Thanks,

    Hasitha.
  • edited 4:36AM
    Hello,

    You cannot pass nhibernate connection to Application connection, it is not supported because there is no connector for nhibernate. You may register instead the IEnumerable objects before calling the report designer:

    report.RegisterData(ienumerable1, "table1");
    report.RegisterData(ienumerable2, "table2");
    report.Design();

    In the designer, you can choose data using the "Data/Choose Report Data" menu.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    Thanks for the swift response. Sorry, its my fault. We have an open IDbConnection which is available in the application. We need to use this as our report database connection without creating another connection. But the problem is "Config.DesignerSettings.ApplicationConnection" does not allow to open connection and it gives an error "Login failed for user 'WMSUSER' in the Query wizard".

    Appreciate your help on this.

    Thanks,

    Hasitha.
  • edited 4:36AM
    FastReport actually does not use the connection object you provide. It creates an own copy of the connector which is compatible with your connection (for ex. own FR class OleDBDataConnection if you use OleDbConnection) and opens it when necessary.
  • HasithaHasitha Sri Lanka
    edited 4:36AM
    Hi,

    Thanks, Is there any workaround for me to use the existing IDbConnection in the report.


    Hasitha.
  • edited 4:36AM
    You cannot use the existing connection directly. FastReport will use a copy of this connection. This is by design.

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.