 |
| Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 26th, 2006, 08:33 AM
|
|
Authorized User
|
|
Join Date: Aug 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Subreport not displying
Hello,
I am using a subreport in my crystal report 9 and using it on asp.net with crystal report viewer. I am pasting the code here. My problem is that, I am not getting subreport datas in disply.
Please help me to solve.
Thanks
Ceema
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
crpt = New Form1A
Dim cmd As New SqlCommand
Dim Da As New SqlDataAdapter
Dim Ds As New DataSet
Dim SchoolID As String
' SchoolID = Session("SchoolID")
Dim ClassID As String
' ClassID = Session("ClassID")
SchoolID = "Ab0"
For Each myTable In crpt.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = "IBRA"
myLogin.ConnectionInfo.DatabaseName = "FSchool"
myLogin.ConnectionInfo.Password = "123"
myLogin.ConnectionInfo.UserID = "sa"
myTable.ApplyLogOnInfo(myLogin)
Next
Dim myConnection As SqlConnection
Dim mySqlDataAdapter As SqlDataAdapter
Dim PName As String
myConnection = New SqlConnection("server=IBRA; uid=sa; pwd=123; database=FSchool")
Da = New SqlDataAdapter("Select * From tmpForm1A where schoolid='" & SchoolID & "'", myConnection)
Da.Fill(Ds.Tables(0))
Me.CrystalReportViewer1.Visible = True
crpt.SetDataSource(Ds)
CrystalReportViewer1.ReportSource = crpt
Ds.WriteXml("c:\backups\testfile.xml")
CrystalReportViewer1.ReportSource = crpt
End Sub
|
|

March 27th, 2006, 02:03 AM
|
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ceema,
It might be the following resons. Pls check these.
1)You have to provide logon infromation to subreport.
Check your code this following block.
'------------------------------------
Private Sub LogOnReport(ByVal cr As CrystalDecisions.CrystalReports.Engine.ReportDocum ent)
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
For Each myTable In cr.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = strInfo(0)
myLogin.ConnectionInfo.DatabaseName = strInfo(1)
myLogin.ConnectionInfo.UserID = strInfo(2)
myLogin.ConnectionInfo.Password = strInfo(3)
myTable.ApplyLogOnInfo(myLogin)
Next
'This below will useful if u have any subreports in main report
Dim RepObject As CrystalDecisions.CrystalReports.Engine.ReportObjec t
Dim SubRepDoc As CrystalDecisions.CrystalReports.Engine.SubreportOb ject
Dim RepDoc As CrystalDecisions.CrystalReports.Engine.ReportDocum ent
For Each RepObject In cr.ReportDefinition.ReportObjects
If RepObject.Kind = CrystalDecisions.Shared.ReportObjectKind.Subreport Object Then
SubRepDoc = CType(RepObject, CrystalDecisions.CrystalReports.Engine.SubreportOb ject)
RepDoc = cr.OpenSubreport(SubRepDoc.SubreportName)
For Each myTable In RepDoc.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = strInfo(0)
myLogin.ConnectionInfo.DatabaseName = strInfo(1)
myLogin.ConnectionInfo.UserID = strInfo(2)
myLogin.ConnectionInfo.Password = strInfo(3)
myTable.ApplyLogOnInfo(myLogin)
Next
End If
Next
End Sub
'------------------------------------
OR
2) Pls check subreports properties.(Right click on subreport and select Fromat there uncheck checkbox if u selected surpress option Or Loadon Demand option.
|
|

March 27th, 2006, 06:52 AM
|
|
Authorized User
|
|
Join Date: Aug 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello VijayKumar,
Thank you for the reply. I have tried the method and now I am using it like the follows, but it's showing th error..Cannot find table 0
Thanks
Ceema
crpt = New Form1A
Dim cmd As New SqlCommand
Dim Da As New SqlDataAdapter
Dim Ds As New DataSet
Dim SchoolID As String
' SchoolID = Session("SchoolID")
Dim ClassID As String
' ClassID = Session("ClassID")
SchoolID = "Ab0"
ClassID = "KG1-A"
For Each myTable In crpt.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = "IBRA"
myLogin.ConnectionInfo.DatabaseName = "FSchool"
myLogin.ConnectionInfo.Password = "123"
myLogin.ConnectionInfo.UserID = "sa"
myTable.ApplyLogOnInfo(myLogin)
Next
Dim RepObject As CrystalDecisions.CrystalReports.Engine.ReportObjec t
Dim SubRepDoc As CrystalDecisions.CrystalReports.Engine.SubreportOb ject
Dim RepDoc As CrystalDecisions.CrystalReports.Engine.ReportDocum ent
For Each RepObject In crpt.ReportDefinition.ReportObjects
If RepObject.Kind = CrystalDecisions.Shared.ReportObjectKind.Subreport Object Then
SubRepDoc = CType(RepObject, CrystalDecisions.CrystalReports.Engine.SubreportOb ject)
RepDoc = crpt.OpenSubreport(SubRepDoc.SubreportName)
For Each myTable In RepDoc.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = "IBRA"
myLogin.ConnectionInfo.DatabaseName = "FSchool"
myLogin.ConnectionInfo.UserID = "sa"
myLogin.ConnectionInfo.Password = "123"
myTable.ApplyLogOnInfo(myLogin)
Next
End If
Next
Dim myConnection As SqlConnection
Dim mySqlDataAdapter As SqlDataAdapter
Dim PName As String
myConnection = New SqlConnection("server=IBRA; uid=sa; pwd=123; database=FSchool")
Da = New SqlDataAdapter("Select * From tmpForm1A", myConnection)
Da.Fill(Ds.Tables(0))
Me.CrystalReportViewer1.Visible = True
crpt.SetDataSource(Ds)
CrystalReportViewer1.ReportSource = crpt
Ds.WriteXml("c:\backups\testfile.xml")
CrystalReportViewer1.ReportSource = crpt
End Sub
|
|

March 27th, 2006, 07:00 AM
|
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ceema,
Cross check ur db once whether 'tmpForm1A' table existed or not in ur database.
|
|

March 27th, 2006, 09:44 AM
|
|
Authorized User
|
|
Join Date: Aug 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello VijayKumar,
tmpForm1a is existing. But, do you thin I have to pass the query like this only, I am new in reports, so I am confused with it's usage.
Thanks
Ceema
|
|

March 28th, 2006, 12:01 AM
|
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

March 28th, 2006, 04:45 AM
|
|
Authorized User
|
|
Join Date: Aug 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello,
Thank you so much.
Ceema
|
|
 |