By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,542 Members | 1,740 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,542 IT Pros & Developers. It's quick & easy.

NullReferenceException when binding to crystalReportViewer.ReportSource

P: n/a
Hi

Thank you for yuour help.

I am using VS.NET 2003 with Crystal XI r2. I am getting
NullReferenceException at the following line in my code.
oRptForm.crystalReportViewer.ReportSource = oReport

I did bind the oDataset with a datagrid to make sure it has data and it
does show 2 tables with data.

Please help me with this.
Private Sub btnShowReport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnShowReport.Click

Dim oDataSet As New ProductivityDataSet()
Dim oReport As New Productivity()
Dim oProductivityReport As New
GsaVoldrBiz.ProductivityReport()
Dim oRptForm As ImmWinForms.ReportViewer

Status.ShowStatus("Generating Productivity Report...")
Me.Cursor = Cursors.WaitCursor

oProductivityReport.GetProductivityReport(oDataSet ,
dtpStartDate.Value, dtpEndDate.Value)
If oDataSet.Productivity.Rows.Count 0 Then
Status.ShowStatus("Loading Productivity Report...")
oReport.SetDataSource(oDataSet)
oReport.SummaryInfo.ReportTitle = "Productivity Report"
oReport.SummaryInfo.ReportComments = "Start Date: " &
dtpStartDate.Text & " End Date: " & dtpEndDate.Text
'Create the Report Form
oRptForm =
ImmWinApplication.AddForm("ProductivityReport",
GetType(ImmWinForms.ReportViewer))

'Set the properties of the Report Form
oRptForm.Text = "Productivity Report"
oRptForm.crystalReportViewer.ShowCloseButton = False
oRptForm.crystalReportViewer.ShowGroupTreeButton =
False
oRptForm.crystalReportViewer.DisplayGroupTree = False
'oRptForm.crystalReportViewer.ReportSource = oReport
Try
DataGrid1.DataSource = oDataSet

oRptForm.crystalReportViewer.ReportSource = oReport
Catch ex As NullReferenceException

End Try
'Me.Cursor = Cursors.Default
'Status.HideStatus()
'Me.Close()
Else
Me.Cursor = Cursors.Default
Status.HideStatus()
MessageBox.Show("There are no records to report on,
please adjust your query and try again", "Search Results",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If

End Sub
End Class

End Namespace

Aug 16 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.