I would like to add a text box to the end of all my reports that dynamically displays all the underlying data sources involved in the report, and each one's underlying sql query.
Can you suggest a way to do this dynamically?
I would like it to be dynamic because I'm lazy and have a LOT of reports to which I'd like to add this, not to mention that I dont want to have to update any static text if the report is changed slightly over time.
Dynamically list each data source and it's underlying query
Dynamically list each data source and it's underlying query
- Attachments
-
- 2018-04-11_9-57-06.png (76.01 KiB) Viewed 3470 times
Re: Dynamically list each data source and it's underlying qu
Hi Ian,
Please add the following method to the 'Code Tab' as per the attached report template:
Then you will be able to use that custom function in the following way in the report:
{GetDataSourcesNames()}
In order to get around easier with the classes and to investigate the properties you need to use, there is an easy trick on how to do that in Visual Studio.
First, you will need to save your report from the designer as 'c# - class' with help of File -> 'Save As' command in the designer. Then just add this class to an empty project in VS - so you will be able to use the Intellisense to navigate through the required for your task classes.
Thank you,
Edward
Please add the following method to the 'Code Tab' as per the attached report template:
Code: Select all
public string GetDataSourcesNames()
{
var result = "";
foreach (var d in Dictionary.DataSources)
{
if (d is Stimulsoft.Report.Dictionary.StiSqlSource)
{
result += "Sql Source - " + (d as Stimulsoft.Report.Dictionary.StiSqlSource).Name + Environment.NewLine;
}
else if (d is Stimulsoft.Report.Dictionary.StiDataTableSource)
{
result += "DataTable Source - " + (d as Stimulsoft.Report.Dictionary.StiDataTableSource).Name + Environment.NewLine;
}
}
return result;
}
{GetDataSourcesNames()}
In order to get around easier with the classes and to investigate the properties you need to use, there is an easy trick on how to do that in Visual Studio.
First, you will need to save your report from the designer as 'c# - class' with help of File -> 'Save As' command in the designer. Then just add this class to an empty project in VS - so you will be able to use the Intellisense to navigate through the required for your task classes.
Thank you,
Edward
- Attachments
-
- CodeTab-GetDataSourcesNames.mrt
- (16.38 KiB) Downloaded 195 times
Re: Dynamically list each data source and it's underlying qu
Thank you much!
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Dynamically list each data source and it's underlying qu
Hello
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.