Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Subreport not showing data Post Reply Post New Topic
Author Message
Wooger
Newbie
Newbie


Joined: 31 Mar 2008
Online Status: Offline
Posts: 2
Quote Wooger Replybullet Topic: Subreport not showing data
    Posted: 31 Mar 2008 at 10:40am
Hi,

I'm using VS2005 C++ to view a Crystal report in the CrystalReportViewer that is embedded in a Form.  I'm having some problem setting the data source in my subreports, whenever I try to do this the subreport never has any data in it even though I know there is data in the DataSet that I just set as the data source.  The main report shows up fine with the correct data. 

 My reports and subreports are being created by hooking up to an XSD file and then I fill the dataset in the code, with each subreport having a different dataset.  Here are some of the ways I have to set the subreport datasource but have had no luck -

 DS = gcnew DataSet("BULDataSet"); //This is the main report dataset

RptCommand = gcnew SqlCommand("SELECT * FROM Subject WHERE Subject.LastName = 'Schroeder'", Conn);

RptAdapter = gcnew SqlDataAdapter(RptCommand);

RptAdapter->Fill(DS);

RptDoc->SetDataSource(DS);  //RptDoc is the main report document

 

subDS = gcnew DataSet("BULDataSet"); //subreport dataset

RptCommand = gcnew SqlCommand("SELECT * FROM Company WHERE Company.Id = 1", Conn);

RptAdapter = gcnew SqlDataAdapter(RptCommand);

RptAdapter->Fill(subDS);

 

RptDoc->Subreports["subreport1"]->SetDataSource(subDS);

or

RptDoc->OpenSubreport("subreport1")->SetDataSource(subDS);

or

 System::Collections::IEnumerator^ EnumSubRpt = RptDoc->Subreports->GetEnumerator();

 while(EnumSubRpt->MoveNext()){

 

SubRptDoc = (ReportDocument^)EnumSubRpt->Current;

SubRptDoc->SetDataSource(subDS);

}

However, I have noticed that if I set my main report dataset as the data source for my subreport or my subreport dataset is taken from the same table that the main report queried, than I can get information to show up on the subreport.

So let's say my main report query was -

SELECT * FROM Subject WHERE Subject.LastName = 'Johnson'

and my subreport query was

SELECT * FROM Subject WHERE Subject.Id = 12345

then data will show up on my subreport, but this is of no use to me since in practice the main dataset and subreport dataset take information from different tables.  What is causing this problem I am having?

IP IP Logged
Wooger
Newbie
Newbie


Joined: 31 Mar 2008
Online Status: Offline
Posts: 2
Quote Wooger Replybullet Posted: 31 Mar 2008 at 12:16pm
I also should note that I am creating the reports using Crystal Reports XI and not the version that is bundled with Visual Studio 2005.
IP IP Logged
pgeorge
Newbie
Newbie


Joined: 17 Apr 2009
Online Status: Offline
Posts: 1
Quote pgeorge Replybullet Posted: 17 Apr 2009 at 4:26am
i realise this was an old post, but did you solve this problem. I have the same issue that the data in subreports are not getting displayed.

I have a report created from xsd and the data in the array inside the object also does not display. Any ideas?
IP IP Logged
mrrcomp
Newbie
Newbie


Joined: 03 May 2011
Online Status: Offline
Posts: 1
Quote mrrcomp Replybullet Posted: 03 May 2011 at 5:00pm
Hi
 
This is a very old post but I have the same type of situation and was wondering if either of you have found the reason or solution.
 
Regards
 
Meir
ConfusedConfusedConfusedConfusedConfusedConfused
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.