Skip to Content
Former Member
Oct 15, 2013 at 03:55 PM

DataTable Based Report Issues


I am working on a reporting framework with will provide Crystal Reports with data in the form of a DataTable rather than using SQL or any other connection as a DataSource and will display the report in the WPF CrystalReportViewer. It works great, if I have DataRows...However if there is no data being provided, I get overwhelmed with "Field is not known" exceptions.

Below is a quick explanation on how the report is displayed:

  1. Gather Data using OData DataService and populate the DataTable.
  2. Load the report, clear the existing DataSources, and then SetDataSource with the provided DataTable.
  3. Display the Report in the WPF Report Viewer

Like I said, everything works if there are records, but if there is not, I get a lot of "Field is not known exceptions". Due to the requirements of this framework, I cannot define a type that the records will be as it needs to be left open for extensibility. End Users may customize the OData results to provide additional fields.

My first question is:

If there is no data being provided, why does Crystal even try to parse the "Detail" bands?

To get around this issue, I am passing in a parameter called "IsEmpty" = true if there is no data in the DataTable. Then, I use formulas to display my data.


if({?IsEmpty}) then "" else {Command.Item}

This leads me to my second question:

If the expression is true, why is the false condition being evaluated? I still get that the "Field is not known" for the "Item" field.

Is there a way to NOT evaluate the "Detail" band or formulas if there is no data?