Feature Post


Crystal Reports Viewer: "This field name is not known.” Error!

Crystal Report Viewer "This field name is not known.” Error!

I was using Crystal Reports Viewer control in my ASP.NET web application; when some of the reports, out of thousands, didn't seem to work. Although, those reports worked fine in Crystal Reports Designer IDE; but when run in my web app, I was thrown this this field name is not known error. So, had to dig in and fix the thing up on production.

Problem symptoms:
  • When trying to view a report in Report Viewer the report prompts for parameters and then gets stuck with an error message box titled "Crystal Report Viewer" and the error is "This field name is not known."
  • Some reports are showing error that "This field name is not known." - problem in report formula?

  • Same report, I can view with CR Designer IDE but CR Viewer (web based) throws the error "This field name is not known.".

Refer to this discussion for more information. And the problem that I was having, see following figure.

Dint find anything useful on Business Objects’s search-unfriendly web forum. Then I came across this Crystal Reports Fix (HTTP location, or FTP location); following two issues made me try this fix:

 Which, un/fortunately didn't work either!

What actually helped, atlast, is this post here on MSDN forum, in guessing” the possible reasons of what might have been going wrong.

Following actually worked:
string strLocation = connectionInfo.DatabaseName + ".dbo." + table.Location.Substring(table.Location.LastIndexOf(".") + 1);

table.Location = strLocation;

So, after applying the new ApplyLogOnInfo(), you will need to set the table location explicitly - again - so that, it would remove old values and apply anew.

Following generic method might help:
private void SetDBLogonToTables(CrystalDecisions.Shared.ConnectionInfo connectionInfo, CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument)
    CrystalDecisions.CrystalReports.Engine.Tables tables = reportDocument.Database.Tables;

    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
        CrystalDecisions.Shared.TableLogOnInfo tableLogonInfo = table.LogOnInfo;

        tableLogonInfo.ConnectionInfo = connectionInfo;

           //Following, did the trick! 
                string strLocation = connectionInfo.DatabaseName + ".dbo." + table.Location.Substring(table.Location.LastIndexOf(".") + 1);

                table.Location = strLocation;
            catch (Exception ex)
Will Rickards has provided a nice example, accessing multiple databases changing the datasource location of the report during runtime.

Someone pretty pissed off, wrote:
“…and no thanks to anyone involved in the development of Crystal Reports. There is no good excuse for the dozens of problems that Crystal Reports has and continues to have.
…so it won't be long before the Crystal company (currently Business Objects?) is sueing Microsoft for putting them out of business by creating a superior product.”

David Hilton in the end, adds to the post that I referred to earlier:
We don't have a good process for publishing the release notes for Crystal Reports to the SDN yet. We are discussing this issue with the program managers to have them released regularly.

Happy crystallizing the reports! (0: