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
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)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()
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


Reply With Quote
