This is a migrated thread and some comments may be shown as answers.

How to return error(string) from dynamic report?

4 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 25 May 2016, 08:44 PM

Hi

I have a situation where i will be generating a bunch of reports that will be dynamically created, converted into pdf files and stored in a folder on the local computer.

The reports are generated in the loop and the data for the report is dynamically accessed through the middle layer. (Report is not connected directly to the database.) I will be accessing the middle layer from the report based on the parameters that were sent from the front end (WinForm). 

There are many chances for me to get the input wrong or the data is not right. I am populating a string "error" with the appropriate error message which needs to return to the winform, which in turn will save the information and keep looping through the sequence to create further reports. 

I couldn't find the way to access the error information, upon returning to winform. (BTW these dynamic reports are never displayed on the form. ) 

Please help me find a way to access error field from the calling form.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 26 May 2016, 02:10 PM
Can someone please point me in the right direction? Thanks.
0
Stef
Telerik team
answered on 27 May 2016, 02:53 PM
Hello Frank,

The ReportProcessor has an Error event that can be used for catching errors during the processing. You can also subscribe each Telerik.Reporting.Report instance to its Error event in order to log issues in the report and to cancel the further processing, if needed.


On a side note, you can verify dynamically generated reports by serializing their settings in XML (TRDX files) - Serialize Report Definition to an XML file. The result can be checked in the Standalone Report Designer tool.


I hope this information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Frank
Top achievements
Rank 1
answered on 27 May 2016, 03:04 PM

Thank you.

What is the best way to set the datasource to the report programmatically.

From with in the event Report_NeedDataSource(object sender, EventArgs e)

or from the winform?  I also have many subreports that uses the Lits<objects> as their datasource.

0
Stef
Telerik team
answered on 31 May 2016, 12:53 PM
Hello Frank,

You can use the report's NeedDataSource - Using Report Events, or you can update the items before processing the report e.g.:
//retrieve an instance of the report     
            var  reportInstance = new MyReport();
       
            //change the report's DataSource settings
            (reportInstance.DataSource as Telerik.Reporting.SqlDataSource).ConnectionString = "new string here";
        
            //change a nested data item's DataSource
            ((reportInstance.Items.Find("table1",true)[0] as Telerik.Reporting.Table).DataSource =GetStoredOnTheServerData();
            //set report parameters values
             reportInstance.ReportParameters["UserId"].Value = GetUserId();
         
             var IRS = new InstanceReportSource { ReportDocument = reportInstance };

If you prefer using expressions, please check the data-binding approaches suggested in the  How to bind Sub Report to Main Report's Data KB article.



Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Stef
Telerik team
Share this question
or