Skip to Content
0

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

Sep 21, 2017 at 11:42 PM

141

avatar image

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Don Williams
Sep 27, 2017 at 01:27 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
OK, I've put a copy of the problem .rpt file here.

Thanks!

0
Don Williams
Sep 22, 2017 at 04:47 PM
0

What version of CR for VS are you using?

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

Don

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Don Williams
Mar 28 at 10:08 PM
0

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


event.jpg (40.5 kB)
Share
10 |10000 characters needed characters left characters exceeded