Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi..Please Give me solution.
I am working on page load event perfectly CrystalReports wrok but same code apply on button click event then display error."Load report failed.".
Load Event Code..
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       If Not IsPostBack Then

           Dim dt As New DataTable
           adp = New SqlDataAdapter("SELECT  * FROM Employee", con)
           Dim ds As New DataSet
           adp.Fill(dt)
           Dim crystalRepo As New ReportDocument()
           crystalRepo.Load(Server.MapPath("~/Test.rpt"))
           crystalRepo.SetDataSource(dt)
           CrystalReportViewer1.ReportSource = crystalRepo


       End If
   End Sub

Button Click Eevent.
VB
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        Dim dt As New DataTable
        adp = New SqlDataAdapter("SELECT  * FROM Employee", con)
        Dim ds As New DataSet
        adp.Fill(dt)
        Dim crystalRepo As New ReportDocument()
        crystalRepo.Load(Server.MapPath("~/Test.rpt"))
        crystalRepo.SetDataSource(dt)
        CrystalReportViewer1.ReportSource = crystalRepo
End If
    End Sub
Posted
Updated 6-Mar-14 18:13pm
v2

 
Share this answer
 
first remove the code on page load then click the button and give a try and after that if it works maybe the test.rpt is open then u need to close the report connection or may be u need to dispose the initial connection.
 
Share this answer
 
Comments
Abhai Oza 7-Mar-14 4:56am    
I have try this code not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900