Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Subreports Not displaying Post Reply Post New Topic
Author Message
Mongoose
Newbie
Newbie
Avatar

Joined: 07 Dec 2006
Location: United States
Online Status: Offline
Posts: 1
Quote Mongoose Replybullet Topic: Subreports Not displaying
    Posted: 07 Dec 2006 at 2:24pm
I have an ASP.NET 2003 application with 3 crystal reports.  Two of them are subreports that display inside the third.  If I try to run the application, it asks me to log on to the server, then displays a blank page.  If I remove the sub-reports and just set the ReportSource to either of the other two reports, it runs perfect without asking me to log in.  It knows the server, database and user, but wants the password.
 
Is there some trick to getting Subreports to display correctly?  I have not had much luck in finding an answer.
 
Here is a code snippet with what I am doing
 
==================================================

selectString = "SELECT ..."  ' not showing actual sql  to save space

Dim dsDaveTest1 As DataSet = New DataSet
Dim hpdata1 As SqlDataAdapter = New SqlDataAdapter(selectString, goConn)
hpdata1.Fill(dsDaveTest1, "MASTER1")
Dim cr1 As CrystalReport1
cr1 = New CrystalReport1
cr1.SetDataSource(dsDaveTest1)
 
selectString = "SELECT ..."  'not showing actual sql string to save space
Dim dsDaveTest2 As DataSet = New DataSet
Dim hpdata2 As SqlDataAdapter = New SqlDataAdapter(selectString, goConn)
hpdata2.Fill(dsDaveTest2, "MASTER2")
Dim cr2 As CrystalReport2
cr2 = New CrystalReport2
cr2.SetDataSource(dsDaveTest2)
 
Dim cr3 As CrystalReport3

cr3 = New CrystalReport3

CrystalReportViewer2.ReportSource = cr3
 
==================================================
 
Thanks in advance....
 
Mongoose
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Dec 2006 at 3:29pm
I have more information about this in my book, but here is the basic way things work. The subreport is part of the main report. So you can't treat the subreport seperately from the main report. Instead, you have to access the subreport object via the main report. Here is some sample code, but you have to fill in the part that actually open the datasource (as you already have listed above). Also, I'm making up the report names, so you have to replace this with your own names.

cr1.SetDataSource(dsDaveTest1)
cr1.OpenSubreport("subreport1").SetDataSource(ds1)
cr1.OpenSubreport("subreport2").SetDataSource(ds2)


IP IP Logged
MacksDaddy
Newbie
Newbie


Joined: 31 Oct 2007
Location: United States
Online Status: Offline
Posts: 1
Quote MacksDaddy Replybullet Posted: 31 Oct 2007 at 7:56am
Brian,
Is there a way to generate the subreport dataset each time the subreport is activated using one of the fields of the main report?
Thanks.
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 17 Dec 2007 at 1:58am
Yes, its possible to activate subreport by using one of the fields using main report. You have to create a link to subreport based on the filed in the main report.  Right click on the subreport and u will get a option
"Change subreport links". By using this option u can create  link between the main report and sub report. I hope i was able to slove ur problem
 
 


Edited by Savan - 17 Dec 2007 at 2:04am
Thanks
Savan
IP IP Logged
Roopangee
Newbie
Newbie
Avatar

Joined: 29 Oct 2008
Online Status: Offline
Posts: 7
Quote Roopangee Replybullet Posted: 31 Oct 2008 at 6:20am
Thanks a lot Brain f for the information..It has helped me create a subrepot!
Thanks again
Roopangee Tandon
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.000 seconds.