on 05-29-2019 1:42 PM
Hello,
I'm working in Visual Studio 2019 and the app is working fine except when I try to export a report, I get an error:
I have tried many different solutions but nothing seems to work.
Help would be very much appreciated.
Thank you in advance!
Damad
Ok, so I've fixed the issue.
If anyone runs into this issue, please make sure that your datasource in the report is correct. In our case it was still connected to the old database and that was the problem. Once changed, it worked fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, You need the same DB client installed on the App server where CR runtime is as the report was created with.
CR is simply passing the DB error code to you from the DB.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
mmm, just confirmed it works for me.
Try a report without parameters and see if that works.
You can't get any more simpler than this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
rpt.Load(@"c:\reports\World Sales Report.rpt");
CrystalReportViewer1.ReportSource = rpt;
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport");
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After I installed some missing NU packages, the error seems to have been resolved. But another error occurred.
Because the database is working on the rest of the project and in the form that I use to create report, I'm not sure what to do.
See if this works:
#region PDF
{
// This works do not alter
// this gets the report name and sets the export name to be the same less the extension
string outputFileName = "";
string MyRptName = rpt.FileName.ToString();
outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);
outputFileName = outputFileName.Substring(0, (outputFileName.Length - 3)) + "pdf";
try
{
if (File.Exists(outputFileName))
{
File.Delete(outputFileName);
}
CrystalDecisions.ReportAppServer.ReportDefModel.PDFExportFormatOptions RasPDFExpOpts = new PDFExportFormatOptions();
try
{
RasPDFExpOpts = rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF);
}
catch (Exception ex)
{
btnSQLStatement.Text = "ERROR: " + ex.Message;
//return;
}
// Set them now:
//RasPDFExpOpts.CreateBookmarksFromGroupTree = false;
//RasPDFExpOpts.EndPageNumber = 1;
//RasPDFExpOpts.StartPageNumber = 1;
// Save the udpated info
if (RasPDFExpOpts != null )
rptClientDoc.set_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPDF, RasPDFExpOpts);
CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
exportOpts1.FormatOptions = RasPDFExpOpts;
// And Export
rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
MessageBox.Show("Export to PDF Completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
btnSQLStatement.Text = "ERROR: " + ex.Message;
return;
}
// This works do not alter
}
#endregion PDF
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
string filePath;
ReportDocument rd = new ReportDocument();
filePath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
rd.Load(filePath + "CrystalReport1.rpt");
rd.SetDatabaseLogon("user", "password", "server", "database");
rd.SetParameterValue("ProgramId", Convert.ToInt32(DropDownList1.SelectedValue));
rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport");
.
.
.
.
That's the code that we have, and the error I mentioned occurs in the last line of the code. It worked on the old server but doesn't on the new one.
Look for access denied errors in the PM log.
Does it work for any other format?
Look in the install log and see if anything failed:
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\logging
Do you have Adobe Reader installed on the Server? It is required.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you install the SP 25 MSI package on the Server.
Use Process Monitor to see where the error is being generated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have SP 25 MSI package on the Server, as far as Process Monitor goes, it's not giving us anything comprehensible.
name.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport");
That's the line of code that's throwing an exception or error, where "name" is ReportDocument.
Error keeps occurring regardless of what we try.
We have tried reinstalling everything. We tried using different frameworks, but the rest of the project is only working in 4.5 and 4.7.2.
We even tried running the whole solution in VS17, but it didn't help.
We are using log4net but not the latest version because when we use the newest version, it's not allowing us the usage in webconfig file.
Same error occurs in the method ExportToDisk
Any suggestion would be much appreciated.
Thanks in advance.
It works in the Viewer and I can check it in the solution, but once I run it locally or on a server it won't export it, providing me with he aforementioned error.
I use VS 2019 and it's the latest CR SP25
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What CR for VS SP are you using?
Does it work exporting from the Viewer?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.