views:

419

answers:

3

I have a Crystal Report that was designed against a dev database. When I load it into the live system I need it to run a different but equivalent database. Normally I just run reports through some code in C# that sets the connection info, parameters and calls VerifyDatabase on the report and subreports and it all works well.

In one particular report this doesn't work though and doesn't seem to verify anything and the report crashes with an error 'The field name is not known' in one of the sub reports. With this report if I manually verify it in the Crystal Reports application against the live database then it all works fine.

So the question is, is there anything different that Verify Database function in the Crystal application does that I should do in code other than set connection info, parameters and call VerifyDatabase method?

Edit: Some more info on what I tried

  1. Get a backup of the live database and put it on our dev environment.
  2. Manually verify the report against this database (which is exactly the same structure as live)
  3. Load the report into the live system and run it.

Error still occurs.

A: 

Could you verify this:

While the debugger is running, if the schema in a typed dataset is changed and you run Verify Database the messagebox always displays "Database up to date" even though there is a difference in the two schemas.

This took me a while to figure out because the Verify Database action was not disabled when the debugger was active.

pipelinecache
Thanks. I am not using typed datasets but connecting directly to the database in the report.
Craig
+1  A: 

The 'field name is not known' error usually means that you have placed a field on the report or used it in a formula (etc), but the field no longer exists in the database. As I understand it, calling VerifyDatabase can update the field list for the views/tables in the report, and can remove fields from the report if they no longer exist, but it cannot fix formulas or subreport links which depend on a missing field.

It seems to me a better practice to make sure that the database is in sync (verified) before deploying the report so you don't need to call VerifyDatabase every time.

All that said, I don't see why it would work after manually verifying, but not after calling VerifyDatabase. Sometimes Crystal is weird that way. You might try recreating the subreport (if it is simple), or removing it and rebinding it to try to trick the error into going away.

Ray
Thanks Ray. I added an edit to the question. The dev database is exactly the same as live, it is a backup, and I manually verified against it, but the error still occurs. I am wondering if different default database collations could cause the problem.
Craig
sometimmes I hate Crystal... The collation is a possibility, though I would guess that would cause sorting problems rather than missing fields. Could there be a different version of Crystal running on dev vs production? Could it be a problem with select permissions on the field in question?
Ray
+1  A: 

It sounds like a confusion between two versions of Crystal and their capabilities. The version that comes with dotNET 2008 is Crystal Reports Basic for VS2008, masquerading as Crystal 10.5 (which doesn't exist as a standalone product). But if you're referring to standalone reports developed by themselves outside of the Visual Studio IDE, then this will be a different version of Crystal with some differences in capability. I'd say this report was created in a different version of Crystal to the others, and that the Verify within the code is coming across some feature that 10.5 can't recognise. If you have a standalone version of Crystal (which will need to be either Crystal Reports 2008, or a Developer edition of an earlier version), use this to make sure you're using the same Crystal version in the app as in in report development.

CodeByMoonlight
Thanks for this. The reports were created in XI which is different to 10.5 which comes with VS2008. But why do the reports run normally in one environment (with 10.5 runtime) and not the other with the same runtime?
Craig
What are the differences between the live and dev dbs? If they were structurally identical, you shouldn't need to Verify at all.
CodeByMoonlight