Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys

I have an application with multiple crystal reports.
I made a lot of forms with report viewers. The application works fine but I want
to have only one form. I used this code in a form:
VB
Private Sub frmReport_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        ControlBox = False
        WindowState = FormWindowState.Maximized
        BringToFront()
        Dim pvCollection As New ParameterValues
        Dim pdvSchYr As New ParameterDiscreteValue
        Dim pdvSem As New ParameterDiscreteValue
        Dim pdvLas As New ParameterDiscreteValue
        Select Case globalfrm
            Case "frmPrintcity"
                Myrpt.Load("..\..\Reports\rptCity.rpt")
                Call DataSourceConnection_Report()
                pdvSchYr.Value = frmPrintcity.cbCompany.Text
                pdvSem.Value = frmPrintcity.cbCity.Text
                pvCollection.Clear()
                pvCollection.Add(pdvSchYr)
                Myrpt.DataDefinition.ParameterFields("@company").ApplyCurrentValues(pvCollection)
                pvCollection.Clear()
                pvCollection.Add(pdvSem)
                Myrpt.DataDefinition.ParameterFields("@city").ApplyCurrentValues(pvCollection)
                Report1.ReportSource = Myrpt
            Case "frmPrintpoi"
                Myrpt.Load("..\..\Reports\rptPoi.rpt")
                Call DataSourceConnection_Report()
                pdvSchYr.Value = frmPrintpoi.cbCompany.Text
                pvCollection.Clear()
                pvCollection.Add(pdvSchYr)
                Myrpt.DataDefinition.ParameterFields("@company").ApplyCurrentValues(pvCollection)
                Report1.ReportSource = Myrpt
            Case "frmPrintpoil"
                Myrpt.Load("..\..\Reports\rptPoin.rpt")
                Call DataSourceConnection_Report()
                pdvSchYr.Value = frmPrintpoil.cbCompany.Text
                pvCollection.Clear()
                pvCollection.Add(pdvSchYr)
                Myrpt.DataDefinition.ParameterFields("@company").ApplyCurrentValues(pvCollection)
                Report1.ReportSource = Myrpt
 End Select
        globalfrm = Nothing

Public Function DataSourceConnection_Report()
        Dim conStr As String = My.MySettings.[Default].ConnectionStr
        Dim arrTemp As String() = conStr.Split(";"c)
        Myrpt.DataSourceConnections(0).SetConnection(arrTemp(0).Split("="c)(1), "RDMS", False)
        Myrpt.DataSourceConnections(0).SetLogon(arrTemp(2).Split("="c)(1), arrTemp(3).Split("="c)(1))
        Return 0
    End Function


The problem is that while displaying the report has no data in it.

Thanks in advance
Posted
Updated 17-Oct-13 2:35am
v2

It would be better if you shared the code of Share the code of DataSourceConnection_Report(). Before processing following things Verify database in your report.

Anyway here possible solutions for this issue.
Crystal Reports: Avoiding Blank Pages[^]
Crystal reports - Mysterious blank pages[^]
Crystal Report Blank / Empty / Not Displaying. No On-Screen Error, But Event Log ‘ConfigurationErrorsException’ Received[^]
 
Share this answer
 
Comments
jomachi 17-Oct-13 8:27am    
Thank you my friend for the responce
jomachi 17-Oct-13 8:37am    
Updated my question with DataSourceConnection_Report()
Hi
please refer this code you will know how to assign multiple reports to the one viewer.

Dim rpt As New CrystalReport1() 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New Dataset1() 'The DataSet you created.
Try
myConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;"
& _
"Initial Catalog=northwind;")
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT * FROM Customers"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "Customers")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
Catch Excep As Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
 
Share this answer
 
Comments
jomachi 17-Oct-13 8:27am    
Thank you my friend for the responce

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900