2011-02-28 192 views
0

當我嘗試打開Crystal報告時加載報告失敗,記錄此錯誤,如果我重新啓動我的iis(iisreset),那麼它的工作。加載報告失敗

這裏是我的代碼:

Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportClass 
Dim location As String = context.Server.MapPath("../POC/POC1.rpt") 
objReport.FileName = location 
objReport.Load() 
objReport.SetDataSource(dsPOC) 

可能是什麼問題呢?

+0

我通常看的時候沒有與報表數據源的問題,此錯誤消息happeneing。您是否嘗試將報告連接直接運行到數據庫服務器? – 2011-02-28 06:50:07

回答

0

嘗試......它會給你完美的想法....

using System;using CrystalDecisions.CrystalReports.Engine;using CrystalDecisions.Shared;namespace Report 
{  public partial class Report : Document  
    {  public void ReportLoad()  
    {    ReportDocument reportDocument = new ReportDocument();  
string filePath = "C:\Projects\Application\Report\CrystalReport.rpt";   reportDocument.Load(filePath); 
      crystalReportViewer.ReportSource = reportDocument; 
     } 
}} 
+0

zunna:什麼是cyrstalreiportViewer是它的任何類的對象。我需要申報嗎? – selvaraj 2011-02-28 07:06:30

+0

是的。它是一個類,你不需要聲明。您可以從此鏈接獲取信息.. http://msdn.microsoft.com/en-us/library/aa665757%28v=vs.71%29.aspx – 2011-02-28 07:10:52

+0

但我找不到任何這樣的類在vb(我的代碼在文件後面是vb) – selvaraj 2011-02-28 07:13:20

0

如果您正在使用VB.net作爲使用本sample code裝載水晶報表後面的代碼。

0

感謝您的回覆。現在通過objReport.Dispose()解決了這個問題。 我在追加每個文檔後調用了Dispose方法。問題可能是我未能釋放數據形式的內存。

問候, SAJ