Search code examples
c#visual-studio-2010crystal-reportscrystal-reports-2010

Crystal Report not displaying data when 1 of DataSet table is empty


I am using Crystal Reports and VS 2010. The Crystal Report is displaying data from 2 tables in a DataSet.

Table 1 (GetReceptionInfo) contains some info in the report header: name, Id, date, time.
Table 2 (SelectReceptionWork) contains records in the details part of the report.

When I am trying to view the CR when there are returned records in Table 2 the CR works fine, but when I try to view it when no records are returned (only in Table 2 but Table 1 HAS records) the Crystal Report is all empty.

I previewed Table 1 from the DataSet and it works fine, but not on the report.

I tried the following steps but the result is still the same (also verified the database after every single change):

  • Removed all links from Database Expert.
  • Set DataSet property of EnforceConstraints to False.
  • Deleted all primary keys on the DataSet.
  • Removed Table 1 from Database Expert and added it again.

Database Expert no links or indexes:

DatabaseExpert no links or indexes

DataSet with no keys, tables are not related:

DataSet with no keys, tables are not related

If the issue is not clear I can post a screenshot of the report, but I'm afraid it might not be clear because it is written in Arabic.


Solution

  • Option A: If GetReceptionInfo and SelectReceptionWorkWhen can be joined. Then you need to join the tables using a left join - not an equal join. When you are on the "Links" tab, click and drag from the field you want to join to the field you want to join to. This will create a little line. THEN, double-click on that line. It will pop-up a page which lets you pick which join type you want. Select "Left Outer Join"

    Option B: If GetReceptionInfo and SelectReceptionWorkWhen are not intended to be joined, then your best bet is to remove the header table (GetReceptionInfo) from the main report. Only include the table SelectReceptionWork. This should list all the data you want. But then you still need to display that header information. So for that, create a SubReport that uses only GetReceptionInfo as its data source, and add that SubReport into the Report Header (or Page Header) section of the crystal report.