Only fetch DataSources which are used

Stimulsoft Reports.NET discussion
Post Reply
Damian
Posts: 7
Joined: Tue May 11, 2010 8:28 am
Location: CH

Only fetch DataSources which are used

Post by Damian »

Hi,

We want to give our users a template report with a lot of prepared DataSources.
The problem is, that while rendering the report every one of these DataSources has its sql statement executed even when the data's aren't used in the report.
Is there a way to restrict execution of the queries to those which are actually used in the report? This would really speed up the report generation.

I experimented a bit with the "Connect on Start" option, but when this option is false, no data at all was fetched.

We use our own Dataadapter derived from StiSqlAdapterService.

Yours sincerely
Damian
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Only fetch DataSources which are used

Post by Jan »

Hello Damian,

Unfortunately does not exist 100% worked code which can say which datasources is used in report. You can try use method RetrievalData of report dictionary. For example:

Code: Select all

Hashtable usedRelations = new Hashtable();
Hashtable usedDataSources = new Hashtable();
Hashtable usedColumns = new Hashtable();

report.Dictionary.RetrievalData(out usedRelations, out usedDataSources, out usedColumns);
This informations can be used for detecting datasources which used in report and which not.

Thank you.
Damian
Posts: 7
Joined: Tue May 11, 2010 8:28 am
Location: CH

Only fetch DataSources which are used

Post by Damian »

Hi,

your code would work while generating the report. But now I'm facing the problem, that the preview of the data does not work in all cases. Especially when this datasource is not added to the report.

Fortunately we did found out, that our users will change the SQLs in 95% of all cases.
So we just prefix our statements with <!-- (results in "<!-- Select * from table" ) and the user can optimize/activate the query. In our Adapter we filter out these datasources.

Thank You for your help
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Only fetch DataSources which are used

Post by Jan »

Hello,

As i wrote before this way is not work in all cases. I'm glad that you have find way resolve your problem.

Thank you.
Post Reply