[英]Export crystal report to PDF
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath(Report));
crystalReport.SetDatabaseLogon("glfuser", "glfuserpass", "glfcol", "");
crvReport.RefreshReport();
crvReport.ReportSource = DAC.GenerateReport(Report, Query);
crvReport.ID = ReportName;
crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\ASD.pdf");
Trying to export my report in PDFformat in my local PC after I get report in report viewer. 在报告查看器中获取报告后,尝试将报告以PDF格式导出到本地PC中。 I am getting report but when I am trying to export it with ExportToDisk method I get error 我正在获取报告,但是当我尝试使用ExportToDisk方法将其导出时,出现错误
Database logon failed. 数据库登录失败。
Description: An unhandled exception occurred during the execution of the current web request. 说明:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。
Exception Details: System.Runtime.InteropServices.COMException: Database logon failed. 异常详细信息:System.Runtime.InteropServices.COMException:数据库登录失败。
Source Error: 源错误:
Line 19: //crvReport.ReportSource = DAC.GenerateReport(Report, Query); 第19行://crvReport.ReportSource = DAC.GenerateReport(Report,Query); Line 20: //crvReport.ID = ReportName; 第20行://crvReport.ID = ReportName; Line 21: crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\\ASD.pdf"); 第21行:crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,@“ D:\\ ASD.pdf”);
我认为您需要在以下行声明数据库
crystalReport.SetDatabaseLogon("glfuser", "glfuserpass", "glfcol", "dbname");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.