Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old March 26th, 2006, 08:33 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


  #2 (permalink)  
Old March 27th, 2006, 02:03 AM
Authorized User
 
Join Date: Sep 2005
Location: Hydrabad, AP, India.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default

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.



  #3 (permalink)  
Old March 27th, 2006, 06:52 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
  #4 (permalink)  
Old March 27th, 2006, 07:00 AM
Authorized User
 
Join Date: Sep 2005
Location: Hydrabad, AP, India.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default

Ceema,

   Cross check ur db once whether 'tmpForm1A' table existed or not in ur database.



  #5 (permalink)  
Old March 27th, 2006, 09:44 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
  #6 (permalink)  
Old March 28th, 2006, 12:01 AM
Authorized User
 
Join Date: Sep 2005
Location: Hydrabad, AP, India.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vijaykumartaduri Send a message via Yahoo to vijaykumartaduri
Default

ceema,

Pls go through these below links, These might be helpful to you

http://msdn.microsoft.com/msdnmag/is...l/default.aspx
http://www.crystalreportsbook.com/default.asp


  #7 (permalink)  
Old March 28th, 2006, 04:45 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

   Thank you so much.

Ceema


Similar Threads
Thread Thread Starter Forum Replies Last Post
displying values in dropdownlistbox imjayakumar Crystal Reports 2 April 3rd, 2007 07:19 AM
subreport srnarla Crystal Reports 1 August 31st, 2006 10:48 AM
subreport bib Visual Basic 2005 Basics 0 August 25th, 2006 12:56 AM
A subreport cannot contain a subreport. dkells Crystal Reports 0 March 3rd, 2005 06:05 PM
Displying Date/time inside a text field spraveens HTML Code Clinic 1 November 14th, 2003 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.