If you became a customer of the Syncfusion� Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion� Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion�.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion� for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion� for your reporting needs.

Consume external IIS hosted Report

Hi,

I am trying to consume an externally hosted report with credentials and parameters with below code. However, when code "writer.Save(memoryStream, format);" it does not throw error but the memorystream object gets 0 length and for "ReadTimeOut" and "WriteTimeOut" with message 'memoryStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'". I am not able to get past this.




internal string GetReportData(string param1, string param2, string reportName, string writerFormat)
{

string retResult = string.Empty;

string ssrs_conn = "http://somedomain/reportserver/";

string ssrs_user = "userID";

string ssrs_pass = "pwdValue";

BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();

writer.ReportProcessingMode = ProcessingMode.Remote;

writer.ReportServerUrl = ssrs_conn;

writer.ReportPath = "/" + "LMS_Report" + "/" + reportName;

writer.ReportServerCredential = new System.Net.NetworkCredential(ssrs_user, ssrs_pass);

List<BoldReports.Web.ReportParameter> userParameters = new List<BoldReports.Web.ReportParameter>();

userParameters.Add(new BoldReports.Web.ReportParameter() { Name = "param1", Values = new List<string>() { param1 } });

userParameters.Add(new BoldReports.Web.ReportParameter() { Name = "Business", Values = new List<string>() { "SME" } });

userParameters.Add(new BoldReports.Web.ReportParameter() { Name = "param2", Values = new List<string>() { param2 } });

writer.SetParameters(userParameters);

string fileName = null;

WriterFormat format;

string type = null;

if (writerFormat == "PDF")

{

fileName = reportName + ".pdf";

type = "pdf";

format = WriterFormat.PDF;

}

else if (writerFormat == "Word")

{

fileName = reportName + ".docx";

type = "docx";

format = WriterFormat.Word;

}

else if (writerFormat == "CSV")

{

fileName = reportName + ".csv";

type = "csv";

format = WriterFormat.CSV;

}

else

{

fileName = reportName + ".xlsx";

type = "xlsx";

format = WriterFormat.Excel;

}

MemoryStream memoryStream = new MemoryStream();

memoryStream.Flush();

// Download the generated export document to the client side.

memoryStream.Position = 0;

writer.Save(memoryStream, format);

FileStreamResult fileStreamResult = new FileStreamResult(memoryStream, "application/" + type);

fileStreamResult.FileDownloadName = fileName;

byte[] bytes = Utils.ReadToEnd(fileStreamResult.FileStream);

return Convert.ToBase64String(bytes);

}


7 Replies

MR Manoranjan Rajendran Syncfusion Team February 3, 2022 11:44 PM UTC

Hi Saurabh,


Thanks for contacting Bold Reports support.


We have validated the reported issue. If an error occurs in report processing, it will generate the 0KB file.  Could you please share your report file along with the error log details with us. We will check the issue and share further details.

https://help.boldreports.com/embedded-reporting/aspnet-mvc-reporting/report-writer/error-logging/


Regards,

Manoranjan R



SB Saurabh Bhatt February 4, 2022 05:59 AM UTC

Hi Manoranjan,


So I am attaching the error file generated for Bold Report here. I have the similar code in .NET Framework but not on BoldReport but rather using Microsoft report viewer and for that I am able to render and get the bytes for PDF report. My Microsoft report viewer code is as below:


ReportViewer ctr = new ReportViewer();

Microsoft.Reporting.WebForms.ReportParameter rpt1 = new Microsoft.Reporting.WebForms.ReportParameter("param1", param1);

Microsoft.Reporting.WebForms.ReportParameter rpt2 = new Microsoft.Reporting.WebForms.ReportParameter("Business", "SME");

Microsoft.Reporting.WebForms.ReportParameter rpt3 = new Microsoft.Reporting.WebForms.ReportParameter("param2", param2);

Microsoft.Reporting.WebForms.ReportParameter[] paramValues = new Microsoft.Reporting.WebForms.ReportParameter[3];


paramValues[0] = rpt1;

paramValues[1] = rpt2;

paramValues[2] = rpt3;


string ssrs_conn = ConfigurationManager.AppSettings["ssrsserverN"].ToString();

string ssrs_user = ConfigurationManager.AppSettings["ssrsuserN"].ToString();

string ssrs_pass = ConfigurationManager.AppSettings["ssrspasswordN"].ToString();


ctr.Reset();


ctr.ServerReport.ReportServerCredentials = new ReportCredentials(ssrs_user.Trim(), ssrs_pass.Trim(), "");

ctr.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

ctr.ServerReport.ReportServerUrl = new System.Uri(ssrs_conn);

ctr.ServerReport.ReportPath = "/" + "Folder_Report" + "/" + Reportname;


ctr.ServerReport.SetParameters(paramValues);

string mimeType, encoding, extension;

string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings;

string format = "pdf";

string filename = Reportname + "." + format;

byte[] bytes = ctr.ServerReport.Render(format, "", out mimeType, out encoding, out extension, out streamids, out warnings);

return Convert.ToBase64String(bytes);


Attachment: ErrorDetails_acb9b0e2.zip


MR Manoranjan Rajendran Syncfusion Team February 5, 2022 01:52 AM UTC

Hi Saurabh,


Thanks for the update.


We have validated the shared error log files. You have to add your data source credentials in your application. Please refer to the below documentation for this.
https://help.boldreports.com/embedded-reporting/aspnet-core-reporting/report-writer/export-ssrs-report/#set-data-source-credential-to-shared-data-sources 

 

Regards,

Manoranjan R



SB Saurabh Bhatt February 7, 2022 03:39 AM UTC

Hi Manoranjan,


I do not understand that in my Microsoft ReportViewer code (which I have pasted in my previous comment) there is no database connection added and yet it works fine. Why do we need to add any database connection here?


Thank you,

S Bhatt



MR Manoranjan Rajendran Syncfusion Team February 8, 2022 01:09 AM UTC

Hi Saurabh,


Thanks for the update.


Microsoft ReportViewer has permission to access the database. For security reasons, others cannot access the report server database automatically. We need credentials to use the database. Please refer to the below documentation for this.

 https://stackoverflow.com/questions/604900/how-to-get-ssrs-data-source-credentials-and-open-an-sql-connection-in-net

Please refer to the below documentation for the Bold Report process.

 https://help.boldreports.com/embedded-reporting/faq/does-bold-report-viewer-uses-the-ssrs-report-processing/



Regards,

Manoranjan R



SB Saurabh Bhatt March 29, 2022 11:03 AM UTC

Hi Manoranjan,


So I have debugged this further and found this weird issue. When I create the List of DataSourceCredentials objects and add the values for the same it works. However when I add this list to the object of

BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();

it does not seem to add. The "writer.DataSources.Count" continues to show 0. My code to add is as below:


BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();

List<BoldReports.Web.DataSourceCredentials> dataSourceCredentialsList = new List<BoldReports.Web.DataSourceCredentials>();

dataSourceCredentialsList.Add(new BoldReports.Web.DataSourceCredentials("XXXXXX", "yyyy", "ZzZzZzZ") { });

writer.DataSources.SetDataSourceCredentials(dataSourceCredentialsList);


This is very very weird.



MR Manoranjan Rajendran Syncfusion Team March 30, 2022 11:46 AM UTC

Hi Saurabh,


Thanks for the update.


You have added the datasource credential details in the report writer control, not the data source details. You set the credentials details in the datasource method. Please use the below code in your application.

 

 

BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();

List<BoldReports.Web.DataSourceCredentials> dataSourceCredentialsList = new List<BoldReports.Web.DataSourceCredentials>();

dataSourceCredentialsList.Add(new BoldReports.Web.DataSourceCredentials("XXXXXX", "yyyy", "ZzZzZzZ") { });

writer.SetDataSourceCredentials(dataSourceCredentialsList);



If you want to get the data source count. Please use the below method to get the data source name.

 var datasource =writer.GetDataSources();


Regards,

Manoranjan R


Loader.
Up arrow icon