'how to load crystal report while button click using vb.net

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 .

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



Solution 1:[1]

VB Solutions runs from "YourSolutionFolder"/Bin/Debug or "YourSolutionFolder"/Bin/Release depending on your configuration.

Hence your rpt file must exist in those folders.

Copy your ClinicianList.rpt files to above folder and then reportDocument.Load("ClinicianList.rpt") will work

Solution 2:[2]

Try this below code

reportDocument.Load(Server.MapPath("CrystalReport.rpt"))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vcs
Solution 2 Jojo