Our own data provider for Report
Hasitha
Sri Lanka
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.
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
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.
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.
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.
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.
Please find the sample project attached herewith.
Thanks,
Hasitha.
Can anyone help me on this. Coz we need to do a demo for our client.
Thanks,
Hasitha.
Looks like the bug in our code. OleDBConnection is replaced by connector to MS Access. Will be fixed in the next daily build.
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.
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.
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.
Thanks, Is there any workaround for me to use the existing IDbConnection in the report.
Hasitha.