我们的旧版VB.Net Web应用程序在尝试从Crystal Reports(版本9.2)导出报表时抛出以下异常:
Exception: CrystalDecisions.CrystalReports.Engine.LogOnException
ErrorID: Logon Failed {6144}
Message: C:/Reports/MyReport.rpt: Unable to connect: incorrect log on parameters
此错误通常是由数据库连接问题引起的,如类似的SO问题所述。但是,我们不会尝试连接到数据库。数据值直接传递到Crystal Reports引擎
代码(缩写)
Dim dataModel As New ReportDataModel 'our data model object
LoadReportData(dataModel) 'our method, extracts data model values from web page
Dim crReportDocument As New ReportDocument 'Crystal object
crReportDocument.Load(...) 'arg here is path to .rpt file that contains report template
Dim parameter As ParameterFieldDefinition 'Crystal object
For Each parameter in crReportDocument.DataDefinition.ParameterFields
SetReportParameters(parameter, dataModel) 'our method, sets value of each Crystal parameter from dataModel
Next
With crReportDocument.ExportOptions
.DestinationOptions = crDiskFileDestinationOptions 'gives destination file path
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export() ' Exception here
我们尝试了什么
我们认为这可能是文件夹权限问题,因为导出操作正在尝试写入本地文件系统。但是,在管理员级帐户下运行应用程序池时,我们仍会看到此错误。
我们希望有关如何进一步诊断此问题的解决方案或任何建议。
答案 0 :(得分:0)
原来这是一只红鲱鱼。事实证明,我们正在创建的报告有一个子报告,实际上确实需要一个数据源,由于不熟悉Crystal Reports,我错过了这个数据源。定义所需的数据源后,问题就解决了。