NullReferenceException when using crystalReportViewer.ReportSource

Discussion in 'ASP .Net' started by roopsd, Aug 15, 2006.

  1. roopsd

    roopsd Guest

    I am using VS.NET 2003 with crystal reports XI release 2. I get a
    runtime error at the following line:

    oRptForm.crystalReportViewer.ReportSource = oReport


    An unhandled exception of type 'System.ExecutionEngineException'
    occurred in mscorlib.dll

    If I put the following statement inside a try catch block, it gives me
    a
    NullReferenceException. I have checked oReport to see that it has data.


    Please help me with this.

    Thanks for your help
     
    roopsd, Aug 15, 2006
    #1
    1. Advertising

  2. roopsd

    Ray Booysen Guest

    roopsd wrote:
    > I am using VS.NET 2003 with crystal reports XI release 2. I get a
    > runtime error at the following line:
    >
    > oRptForm.crystalReportViewer.ReportSource = oReport
    >
    >
    > An unhandled exception of type 'System.ExecutionEngineException'
    > occurred in mscorlib.dll
    >
    > If I put the following statement inside a try catch block, it gives me
    > a
    > NullReferenceException. I have checked oReport to see that it has data.
    >
    >
    > Please help me with this.
    >
    > Thanks for your help
    >

    Can you post some of your code please?
     
    Ray Booysen, Aug 15, 2006
    #2
    1. Advertising

  3. roopsd

    roopsd Guest

    The following line is where it errors giving a null reference
    exception:
    oRptForm.crystalReportViewer.ReportSource = oReport

    I have tried binding the oDataSet to a datagrid, it does show me 2
    tables of values.

    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






    roopsd wrote:
    > I am using VS.NET 2003 with crystal reports XI release 2. I get a
    > runtime error at the following line:
    >
    > oRptForm.crystalReportViewer.ReportSource = oReport
    >
    >
    > An unhandled exception of type 'System.ExecutionEngineException'
    > occurred in mscorlib.dll
    >
    > If I put the following statement inside a try catch block, it gives me
    > a
    > NullReferenceException. I have checked oReport to see that it has data.
    >
    >
    > Please help me with this.
    >
    > Thanks for your help
     
    roopsd, Aug 16, 2006
    #3
  4. roopsd

    roopsd Guest

    Hi!
    Thank you for looking at it.

    I get a NullReferenceException at the following line:
    oRptForm.crystalReportViewer.ReportSource = oReport

    I have tried binding the oDataset to datagrid to make sure it has data,
    it does show 2 tables with data.

    Please advice what I should do.

    Thank you.


    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



    Ray Booysen wrote:
    > roopsd wrote:
    > > I am using VS.NET 2003 with crystal reports XI release 2. I get a
    > > runtime error at the following line:
    > >
    > > oRptForm.crystalReportViewer.ReportSource = oReport
    > >
    > >
    > > An unhandled exception of type 'System.ExecutionEngineException'
    > > occurred in mscorlib.dll
    > >
    > > If I put the following statement inside a try catch block, it gives me
    > > a
    > > NullReferenceException. I have checked oReport to see that it has data.
    > >
    > >
    > > Please help me with this.
    > >
    > > Thanks for your help
    > >

    > Can you post some of your code please?
     
    roopsd, Aug 16, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Watkins

    CrystalReportViewer ReportSource problem

    Brian Watkins, Jul 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,595
    Brian Watkins
    Jul 10, 2003
  2. Shannon Cayze
    Replies:
    0
    Views:
    473
    Shannon Cayze
    Jul 22, 2003
  3. Aaron Ackerman
    Replies:
    1
    Views:
    5,294
    Aaron Ackerman
    Feb 16, 2004
  4. roopsd
    Replies:
    0
    Views:
    537
    roopsd
    Aug 16, 2006
  5. Aaron Ackerman
    Replies:
    1
    Views:
    363
    Aaron Ackerman
    Feb 16, 2004
Loading...

Share This Page