Results 1 to 2 of 2

Thread: Crystal Report Not displaying data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    Crystal Report Not displaying data

    Hi Guys

    I have 3 table in my Crystal Report Field Explorer, Which i use in the Report.

    The problem is if i add a Field on my report from one table it works fine, but if i drag fields from 2 or 3 tables on the report no data is displayed.

    Here is my mane code on a button click

    Code:
       Dim JobNo As String
            JobNo = InputBox("Enter No")
    
            Dim ReportForm As New JobReport
    
            Dim TableName(2) As String
    
            Dim QueryString(2) As String
    
            TableName(0) = "Jobs" 'Pass The Table That you used in the crystal Report
            TableName(1) = "Comments"
            TableName(2) = "DescriptionOfWokDone"
    
            QueryString(0) = "SELECT * FROM Jobs Where JobNo=('" & JobNo & "')"
            QueryString(1) = "SELECT * FROM Comments Where JobNo=('" & JobNo & "')"
            QueryString(2) = "SELECT * FROM DescriptionOfWorkDone Where JobNo=('" & JobNo & "')"
        
            ReportViewer.ViewReport("Jobreport.rpt", TableName, QueryString, )
            ReportViewer.Show()
    Sorry just re checked it. If i add fields from the "Job Table on the Crytal Report it works. It doesn;t display any data if i add anything from any other table ("Comments,DescriptionOfWorkDone)

    Here is the rest of the code
    Code:
    [Public Function GetDataAdeptor(ByVal QueryString As String) As SqlDataAdapter
    
    
    
            Try
                cn = New SqlConnection(connectionString)
    
    
                da = New SqlDataAdapter(QueryString, cn)
    
                Return da
    
            Catch ex1 As SqlException
                Throw New Exception("Error Getting The Table", ex1)
    
            Catch ex As Exception
    
                Throw New Exception("Error Getting The DataAdapter", ex)
    
            End Try
    
    
    
        End Function
    
    
        Friend Sub ViewReport(ByVal ReportName As String, ByVal TableName() As String, ByVal QueryString() As String, Optional ByVal [Parameter] As String = "")
    
    
            If Not UBound(TableName).Equals(UBound(QueryString)) Then MessageBox.Show("Passed Variable Are Not Correct", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information) : Exit Sub
    
            Dim Report As New JobReport
            Dim Adapter As New SqlDataAdapter
    
            Dim ds As New DataSet
    
    
    
            For I As Integer = 0 To UBound(TableName)
    
                Adapter = GetDataAdeptor(QueryString(I))
    
                Adapter.Fill(ds, TableName(I))
    
            Next
    
            'Report In the report Folder
    
            Report.Load(Application.StartupPath & "/JobReport.rpt")
    
            Report.SetDataSource(ds)
    
    
            If Not [Parameter] = "" Then Report.SetParameterValue(0, [Parameter])
    
            Me.CrystalReportViewer1.ReportSource = Report
    
    
    
        End Sub

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Crystal Report Not displaying data

    Thread moved to Reporting forum - hopefully you'll get some assistance here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width