cancel
Showing results for 
Search instead for 
Did you mean: 

"This field name is not known." from ReportDocument.Load(), so how to VerifyDatabase?

davehuang
Explorer
0 Kudos

I have a Crystal Report file that I'm unable to even load, using the following VB.NET code:

Dim objRptDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
objRptDoc.Load("C:\path\to\my.rpt")


It throws a CrystalDecisions.Shared.CrystalReportsException

Message: Load report failed.
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)

With an InnerException of type System.Runtime.InteropServices.COMException

Message: This field name is not known.
Details: errorKind
Error in File my 17320_16748_{19E5E493-1D64-4084-8E97-6395D78D94EB}.rpt:
Error in formula SubTotal Label:
'If {Invoice.ForeignSubTotal} = {Invoice.ForeignTotalAmount} Then
'
This field name is not known.
Details: errorKind

at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

Now I more or less know what the problem is... if I open the report in the Crystal Designer, do a Verify Database, and save it, it'll work fine. But I want to be able to do this automatically from my own code, rather than telling the user that they need to go run Verify Database on the report (especially since the user probably will not have access to the Crystal report designer). Normally, I'd call the ReportDocument.VerifyDatabase() method, but that assumes I already have the report loaded into the ReportDocument object. Since I can't even Load the report, I can't call VerifyDatabase.

Any advice on how I can accomplish this?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Interesting.... So it would appear your only option is to specifically test for the Inner Exception and pop up a message box "The report requires Verifying the Database in CR Designer only, the CR SDK is not capable of doing this at runtime"

I've never seen this error before on open, it does suggest the report relies heavily on that field. Because the Engine loads all objects into memory and then validates them on open your only option is to fix the report first.

I would still like the report so I can pass it by R&D to see if we can improve things on Open....

Thanks again

Don

davehuang
Explorer
0 Kudos
OK, I've put a copy of the problem .rpt file here.

Thanks!

Answers (2)

Answers (2)

0 Kudos

Thank you for the report.

I get this error in my Event handler, I have multiple so not sure which one is triggering it. Click on the CR Viewer and you'll be able to see which events you can trigger on.


The formula looks normal

I also get an error the saved data will be discarded in CR

Don

0 Kudos

What version of CR for VS are you using?

Later versions do not test the formula fields unless you specifically check them.

Don

davehuang
Explorer
0 Kudos

Hi, I'm using CR Developer for Visual Studio 13 SP21 (13.0.21.2533).

I'll see if I can supply the .rpt file that demonstrates the problem.