LoadSaveReportException 未处理/报告文件路径无效

LoadSaveReportException was unhandled / Invalid report file path

这是我第一次使用 Crystal 报告。 我想做的是 当我突出显示 datagridview 中的一行并单击报告按钮时, 只有突出显示的行会显示在 Crystal 报告查看器中,如图所示。

举报按钮代码

  Private Sub btnReport_Click(sender As Object, e As EventArgs) Handles btnReport.Click
        Dim report As New ReportDocument
        report.SetParameterValue("StudentRecord", dgv1.SelectedRows(0).Cells(0).Value)
        report.Load("C:\Users\harold\Documents\Visual Studio 2012\Projects\SASApp\SASApp\MyReport.rpt")
        CrystalReportViewer1.ReportSource = report
        CrystalReportViewer1.Refresh()
    End Sub

每当我点击报告按钮时,我都会收到

错误

LoadSaveReportException was unhandled / Invalid report file path with this line

report.SetParameterValue("StudentRecord", dgv1.SelectedRows(0).Cells(0).Value)

我在 Crystal 报告的参数字段中得到了 "StudentRecord",如下图所示

谁能帮我弄清楚我的代码有什么问题。谢谢

我相信您需要在设置参数之前先加载报表。它正在尝试将参数设置为未加载的报告。