如何在使用 vb.net 单击按钮时加载水晶报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18864783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to load crystal report while button click using vb.net
提问by user1702346
I have a code to load crystal report while clicking a button in vb.net but it gives load failed error please help me to solve this .
我有一个代码可以在单击 vb.net 中的按钮时加载水晶报告,但它给出了加载失败错误,请帮我解决这个问题。
my code is
我的代码是
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
thank you in advance
先感谢您
geetha
盖塔
回答by vcs
VB Solutions runs from "YourSolutionFolder"/Bin/Debugor "YourSolutionFolder"/Bin/Releasedepending on your configuration.
VB 解决方案从 “YourSolutionFolder”/Bin/Debug或“YourSolutionFolder”/Bin/Release 运行,具体取决于您的配置。
Hence your rptfile must exist in those folders.
因此,您的rpt文件必须存在于这些文件夹中。
Copy your ClinicianList.rptfiles to above folder and then reportDocument.Load("ClinicianList.rpt")will work
将您的ClinicianList.rpt文件复制到上述文件夹,然后reportDocument.Load("ClinicianList.rpt")将起作用
回答by SHEIK ANAS
Try this below code
试试下面的代码
reportDocument.Load(Server.MapPath("CrystalReport.rpt"))

