Quantcast
Channel: VBForums - Reporting
Viewing all articles
Browse latest Browse all 594

Load Report Failed - Crystal Reports

$
0
0
I have a vs2010 winforms app with sql 2008 r2 backend. I am trying to run a crystal report from within my app. I have a form with the CrystalReportViewer on it and I have a form with a button running the code to open the viewer and load the report.

I get the "Load Report Failed" error. The report takes a parameter and I have a textbox on the crystalreportviewer form to allow the user to enter a value or change the value, but it crashes on the load and doesn't even get to that code. If I choose the report from the smart tag on the CrystalReportViewer the report will load and prompt for the paramater value. I cannot figure out how to be able to programmically load the report and then have user enter parameter.

Here is the code I use to load the report.
Code:

        Dim zcrystalviewer As New CrystalReportViewer
        zcrystalviewer.Show()
        Dim cryRpt As New ReportDocument
        cryRpt.Load("C:\Member Program\Member Program\Member Program\Reports\statelist.rpt")

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = TextBox1.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("zState")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        zcrystalviewer.CrystalReportViewer1.ReportSource = cryRpt
        zcrystalviewer.CrystalReportViewer1.Refresh()

It crashes on this line of code: cryRpt.Load("C:\Member Program\Member Program\Member Program\Reports\statelist.rpt").

I have this same report without the parameter and it loads (cryRpt.Load("C:\Member Program\Member Program\Member Program\Reports\worldir.rpt")) just perfectly.

What am I doing wrong? Can I load the report first before getting the parameter?

Thanks!
Stacy

P.S. I did a tutorial and this is exactly how they did it in the tutorial and that one works. It had one parameter and they could change it in the textbox and reload the report with the new parameter.

Viewing all articles
Browse latest Browse all 594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>