ASP.Net中的Crystal Report加载失败 - 2010
问题描述:
嗨..请给我解决方案。
我正在完成页面加载事件CrystalReports wrok但同样的代码适用于按钮点击事件然后显示错误。加载报告失败。。
加载事件代码..
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..
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
按钮单击Eevent。
Button Click Eevent.
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
答
检查此提示/技巧
Crystal Reports:修复加载报告失败错误。 [ ^ ]
Check this Tip/Trick
Crystal Reports: Fix for "Load report failed" error.[^]
首先删除页面加载上的代码,然后单击按钮并尝试一下,如果它工作,可能test.rpt打开然后你需要关闭报告连接,或者你需要处理初始连接。
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.