0

我有一个代码可以在单击 vb.net 中的按钮时加载水晶报告,但它会给出加载失败错误,请帮我解决这个问题。

我的代码是

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Public Class ClinicianListRpt

Private reportDocument As New ReportDocument()
Dim paramField As New ParameterField()
Dim paramFields As New ParameterFields()
Dim paramDiscreteValue As New ParameterDiscreteValue()
Private Sub ClinicianListRpt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    CrystalReportViewer1.DisplayGroupTree = False

    reportDocument.Load("ClinicianList.rpt")
    CrystalReportViewer1.ReportSource = reportDocument

    CrystalReportViewer1.ReportSource = reportDocument
    reportDocument.SetDatabaseLogon("sa", "manager", "172.16.7.8", "SPEECH")
End Sub
End Class

先感谢您

吉萨

4

2 回答 2

0

试试下面的代码

reportDocument.Load(Server.MapPath("CrystalReport.rpt"))
于 2013-12-13T07:54:32.873 回答
0

VB Solutions 从 “YourSolutionFolder”/Bin/Debug“YourSolutionFolder”/Bin/Release运行,具体取决于您的配置。

因此,您的rpt文件必须存在于这些文件夹中。

将您的ClinicianList.rpt文件复制到上述文件夹,然后reportDocument.Load("ClinicianList.rpt")将起作用

于 2013-09-18T10:41:42.577 回答