Solved

Crystal Report does not show data when 1 of the 2 datatables in dataset return empty rows

Posted on 2004-04-27
11
1,961 Views
Last Modified: 2012-06-27
Hi all, I'm using VS.net and crystal reports and currently facing this problem.

I have 2 datatables in the dataset

The first datatable is queried from the stored prod in sql sever 2000.
The second is a date, made into a datatable and added as a second table to the dataset that was queried

                        'Add datefrom and dateto into dataset
                        Dim dt As DataTable = New DataTable
                        Dim dr As DataRow
                        dt.Columns.Add("StartDate", Type.GetType("System.DateTime"))
                        dt.Columns.Add("EndDate", Type.GetType("System.DateTime"))
                        dr = dt.NewRow()
                        dr(0) = startDate
                        dr(1) = endDate
                        dt.Rows.Add(dr)
                        dt.TableName = "Table1"
                        ds.Tables.Add(dt)

The report shows fine when the first datatable return rows but when it the first datatable returns no rows, I still want the report to show the values of the secondtable.

Help Needed, Much Appreciated
0
Comment
Question by:alvinlau
  • 6
  • 4
11 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
You need to change your relations into CR between your 2 tables from INNER JOIN to LEFT JOIN (into the Visual Linking).

Sorry not being able to be more precise as I don't have .Net on this PC right now!

0
 
LVL 42

Expert Comment

by:frodoman
Comment Utility
emoreau is correct.  

Go to your report and in Field Explorer right-click on Database Fields and select "Visual Linking Expert".  Then select the links tab.   Click directly on the line linking the tables and this will enable the "Link Options" button.  Click it, then change the link type from "Inner Join" to "Left Outer Join"

0
 

Author Comment

by:alvinlau
Comment Utility
Hi, the 2 tables are not linked together. Its just purely a dataset with 2 datatables passed through. Here is the xsd of it.

<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-GB">
        <xs:complexType>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="Table">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="ID" type="xs:string" minOccurs="0" />
                            <xs:element name="DepCode" type="xs:string" minOccurs="0" />
                            <xs:element name="ListedCountryCode" type="xs:string" minOccurs="0" />
                            <xs:element name="AccountGroup" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="table2">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="dateFrom" type="xs:dateTime" minOccurs="0" />
                            <xs:element name="dateTo" type="xs:dateTime" minOccurs="0" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
It is not the schema. It is really the report.

Right-click anywhere it's grey on your report, select Database from the popup menu and then "Visual Linking expert".
From the "Database Expert" dialog, right-click the link between the tables and select "Link Options".
From the "Link Options" dialog, select "Left Outer Join" as the join type.
0
 

Author Comment

by:alvinlau
Comment Utility
I went to Visual Linking expert and there are no link joining the 2 tables together.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
If your 2 tables are used in the Details, add links and be sure they are Left Joined
0
 

Author Comment

by:alvinlau
Comment Utility
Hi emoreau,

Thanks for being with me.

The second table contains the dateFrom and dateTo columns with 1 row. This datatable is used in the header portion of CR to display the stored input dates that the user keys from the web application. This datatable is added to dataset which contains the first table(used in the details section of the CR) that is queried from the database. So if there is no rows returned, I want the dateFrom and dateTo to be still shown in the header portion. Unfortunately, it does show only when the first table contains rows.

There is no relation between the both tables and I don't see a need to link the tables. Thanks

Help still needed =)
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 70 total points
Comment Utility
You don't need a datatable to pass that kind of values.

Add textobjects to your report, set their (name) and use this method to set their values:

    Protected Sub ApplyTextObject(ByVal vstrTextObject As String, ByVal vstrTextValue As String)
        Try
            CType(ReportToPrint.ReportDefinition.ReportObjects(vstrTextObject), CrystalDecisions.CrystalReports.Engine.TextObject).Text = vstrTextValue

        Catch ex As Exception
            'For i As Int32 = 0 To ReportToPrint.ReportDefinition.ReportObjects.Count - 1
            '    Trace.WriteLine(ReportToPrint.ReportDefinition.ReportObjects(i).Name)
            'Next
            Throw ex
        End Try
    End Sub

0
 

Author Comment

by:alvinlau
Comment Utility
Hey emoreau,

I'm trying your method now, how do you set the name to the text objects?
0
 

Author Comment

by:alvinlau
Comment Utility
Silly me I've found it. I think I'll be able to proceed from here thanx
0
 

Author Comment

by:alvinlau
Comment Utility
hey thanx emoreau, it certainly solved my prob. Kudos to ya
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now