Some questions

Stimulsoft Reports.NET discussion
Post Reply
Tommaso
Posts: 8
Joined: Thu Jul 20, 2006 5:44 am
Location: Italy

Some questions

Post by Tommaso »

Hello, I'm evaluating StimulReport to use it in my .NET applications. I tried it for a couple of days, and I found it's very fast compared to other reporting tool, such as Active Reports, Crystal Reports, DevExpress XtraReports and Perpetuum Report Sharp-Shooter, so I think I'm going to purchase it. :grinder:

Now I want to setup my report developing in such a way:
- create reports using direct connection to database (e.g SqlServer), for a quicker creation of data sources (a Crystal Reports-like approach)

- in runtime populate dataset with my own code (with DAL + stored procedures) and then set report's datasources to them
I want to do this because I need to support multiple databases (SqlServer, Oracle, and possibly others), and moreover I want reports showing data filtered by user; for example users can filter a datagrid with some custom filter form; then, if they print a report I want the report show the same datagrid data with the same filter conditions, with possibly complex queries

I tried setting datasource's ConnectOnStart to False, loading dataset with my custom filters and then using RegData to set report data, but it doesn't work, and report is empty; if I don't set ConnectOnStart to False, report loads data directly from database, and ignores my custom dataset.
I think with StimulReport I can reach my goal, but I can't understand how. I need some help and guidelines to do this

Best regards
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Some questions

Post by Vital »

Thanks for your questions.

What you need to do:

1. Because you get data from Sql Server from designer you are use datasource based on sql source.
So in runtime you need replace this datasources by datasources based on DataSet. How to do this?

Code: Select all

StiReport report = new StiReport();

//Load report from any source
report.Load("MyReport.mrt");

//Remove all datasource from report dictionary
report.Dictionary.Datasources.Clear();

//Bind data in DataSet
report.RegData("MyDataSet", dataSet);
At this moment you don't have any datasource in report. So you need create it automaticaly based on
dataSet.

Code: Select all

report.Dictionary.Synchronize();
after this action report engine creates new datasources based on tables in dataset. But you need to use equal table names
and column names in report before and after this action. For example, if you create datasource in report dictionary
with name "SqlCustomers" based on query then you need to create equal table in dataset with name "SqlCustomers".
if you have column "SqlName" then you need equal column in table with name "SqlCustomers".

After this action you will get updated report and can run it.

2. About filter. Use the following code to change filter:

Code: Select all

report.Load("report.mrt");
report.RegData("MyDataSet", dataSet);

StiDataBand band = report.GetComponents()["DataBand1"] as StiDataBand;
band.Filter.Value = "{Customers.Code == 1}";

report.Compile();
report.Render();
If you will have any problems with this questions you can on forum or on Image
Thanks.





Tommaso
Posts: 8
Joined: Thu Jul 20, 2006 5:44 am
Location: Italy

Some questions

Post by Tommaso »

Thanks, I missed report.Dictionary.Synchronize() call

Other questions:
- for performance purposes, it's better to populate dataset from code or let StimulReport do it?
- settings dataBand.Filter.Value works on whole data from db or data is pre-filtered in sql execution? in other words, data filtering is executed "db-side" or "report-side"?
- in case of master-detail reporting, does StimulReport load all detail rows and then match with master row, or for each master row executes a different detail query?

I think another way to support both SqlServer and Oracle is using OleDbConnections and OleDbDataSources in report design and then changing in runtime connection infos; but I found that in report desing OleDbConnections don't work well, because, for example, I can't automatically retrieve columns from sql queries to create OleDbDataSources; and when you test connection, there's a error like "key word "provider" not supported"; it seems like the test of connection uses just SqlConnections; and the same behavior occurs in report preview

I need these infos to decide what report development strategy fits better for our purposes.

Best regards,

Tommaso
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Some questions

Post by Edward »

Tommaso wrote:Thanks, I missed report.Dictionary.Synchronize() call
Other questions:
- for performance purposes, it's better to populate dataset from code or let StimulReport do it?
Both methods of using data are the same for performance.
Tommaso wrote:- settings dataBand.Filter.Value works on whole data from db or data is pre-filtered in sql execution? in other words, data filtering is executed "db-side" or "report-side"?
Setting the dataBand.Filter.Value is executing "report-side" way.
Tommaso wrote:- in case of master-detail reporting, does StimulReport load all detail rows and then match with master row, or for each master row executes a different detail query?
In case of using SQL queries each master row executes detail query and loads only self detail rows (ReconnectOnEachRow property of Detail query).
Tommaso wrote:I think another way to support both SqlServer and Oracle is using OleDbConnections and OleDbDataSources in report design and then changing in runtime connection infos; but I found that in report desing OleDbConnections don't work well, because, for example, I can't automatically retrieve columns from sql queries to create OleDbDataSources; and when you test connection, there's a error like "key word "provider" not supported"; it seems like the test of connection uses just SqlConnections; and the same behavior occurs in report preview
I need these infos to decide what report development strategy fits better for our purposes.
Best regards,
Tommaso
If you use OledbConnection then you need to use Datasource from OleDb Connection. If you use SqlConnection you need to use SqlSource from SQL Connection.
Thanks!
Tommaso
Posts: 8
Joined: Thu Jul 20, 2006 5:44 am
Location: Italy

Some questions

Post by Tommaso »

Thanks for reply
Edward wrote: If you use OledbConnection then you need to use Datasource from OleDb Connection. If you use SqlConnection you need to use SqlSource from SQL Connection.
Thanks!
That's right.
But I think there's a little "bug" in designer; to reproduce follow these steps:
1) create a new report
2) create a new SqlConnection
3) create a new SqlDataSource
4) try to create a new OleDbConnection; when you test it, you get "key-word 'provider' not supported"

even if you delete all defined SqlDataSources and SqlConnections, you get the same behavior; the only solution is to save, close and re-open report

Best Regards
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Some questions

Post by Edward »

Tommaso wrote:Thanks for reply
Edward wrote: If you use OledbConnection then you need to use Datasource from OleDb Connection. If you use SqlConnection you need to use SqlSource from SQL Connection.
Thanks!
That's right.
But I think there's a little "bug" in designer; to reproduce follow these steps:
1) create a new report
2) create a new SqlConnection
3) create a new SqlDataSource
4) try to create a new OleDbConnection; when you test it, you get "key-word 'provider' not supported"

even if you delete all defined SqlDataSources and SqlConnections, you get the same behavior; the only solution is to save, close and re-open report

Best Regards
Thank you for this bug.
Please contact us to recieve patch at Image. Please specify .Net version you are using.
Thanks.
Post Reply