在网上下了一个C#的实例,按照里面说明更改了一下数据库连接信息并重新生成,没有发现任何错误.但一找开浏览器运行时,出现以下错误:----------------
加载报表失败。 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: 加载报表失败。Source Error: 
Line 75: 
Line 76:  //Pass the populated dataset to the report
Line 77:  crReportDocument.SetDataSource(dataSet);
Line 78: 
Line 79:  //Set the viewer to the report object to be previewed.
 Source File: c:\inetpub\wwwroot\crnetsamples\csharp_web_adonet\webform1.aspx.cs    Line: 77 Stack Trace: [LoadSaveReportException: 加载报表失败。]
   .F(String  , EngineExceptionErrorID 
) +273
   .B(String , Int32 ) +64
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob) +1162
   CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob) +519
   CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(Object value) +276
   CSharp_web_adonet.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\crnetsamples\csharp_web_adonet\webform1.aspx.cs:77
   System.Web.UI.Control.OnLoad(EventArgs e) +102
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1064--------------------------------------------------源文件如下:-----------------crystalReport1.cs---------------namespace CSharp_web_adonet {
    using System;
    using System.ComponentModel;
    using CrystalDecisions.Shared;
    using CrystalDecisions.ReportSource;
    using CrystalDecisions.CrystalReports.Engine;
    
    
    public class CrystalReport1 : ReportClass {
        
        public CrystalReport1() {
        }
        
        public override String ResourceName {
            get {
               // return "CrystalReport1.rpt";
                
return "CrystalReport1.rpt";
            }
            set {
                // Do nothing
            }
        }
        
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Section Section1 {
            get {
                return this.ReportDefinition.Sections[0];
            }
        }
        
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Section Section2 {
            get {
                return this.ReportDefinition.Sections[1];
            }
        }
        
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Section Section3 {
            get {
                return this.ReportDefinition.Sections[2];
            }
        }
        
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Section Section4 {
            get {
                return this.ReportDefinition.Sections[3];
            }
        }
        
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Section Section5 {
            get {
                return this.ReportDefinition.Sections[4];
            }
        }
    }
    
    [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")]
    public class CachedCrystalReport1 : Component, ICachedReport {
        
        public CachedCrystalReport1() {
        }
        
        public virtual Boolean IsCacheable {
            get {
                return true;
            }
            set {
                // 
            }
        }
        
        public virtual Boolean ShareDBLogonInfo {
            get {
                return false;
            }
            set {
                // 
            }
        }
        
        public virtual TimeSpan CacheTimeOut {
            get {
                return CachedReportConstants.DEFAULT_TIMEOUT;
            }
            set {
                // 
            }
        }
        
        public virtual ReportDocument CreateReport() {
            CrystalReport1 rpt = new CrystalReport1();
            rpt.Site = this.Site;
            return rpt;
        }
        
        public virtual String GetCustomizedCacheKey(RequestContext request) {
            String key = null;            return key;
        }
    }
}---------------webform1.aspx.cs--------------------
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.OleDb;using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace CSharp_web_adonet
{
public class WebForm1 : System.Web.UI.Page
{ //CR Variable
CrystalReport1 crReportDocument; //ADO.NET Variables
OleDbConnection adoOleDbConnection;
OleDbDataAdapter adoOleDbDataAdapter;
DataSet dataSet; protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//Build a connection string
string connectionString= "";
connectionString = "Provider=SQLOLEDB;";
connectionString += "Server=qiaoqiao;Database=pubs;";
connectionString += "User ID=sa;Password=puneats77"; //Create and open a connection using the connection string
adoOleDbConnection = new OleDbConnection(connectionString); //Build a SQL statement to query the datasource
string sqlString = "";
sqlString = "Select *  From authors"; //Retrieve the data using the SQL statement and existing connection
adoOleDbDataAdapter = new OleDbDataAdapter(sqlString, adoOleDbConnection); //Create a instance of a Dataset
dataSet = new DataSet1(); //Fill the dataset with the data retrieved.  The name of the table
//in the dataset must be the same as the table name in the report.
adoOleDbDataAdapter.Fill(dataSet, "authors");


//Create an instance of the strongly-typed report object
crReportDocument = new CrystalReport1(); //Pass the populated dataset to the report
crReportDocument.SetDataSource(dataSet); //Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument; } #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
-------------------------------------------------请问各位这是什么原因引起的呢?又如何解决?

解决方案 »

  1.   

    报表已经注册了.我用不同的方法加载报表,总是说加载报表失败.---------------------
    加载报表失败。 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: 加载报表失败。Source Error: 
    Line 38:  //string path;
    Line 39:  //path=Server.MapPath ("CrystalReport1.rpt");
    Line 40:  oRpt.Load ("C:\\Inetpub\\wwwroot\\view\\CrystalReport1.rpt");-----------------------究竟是什么原因呢?
     
      

  2.   

    总是出现"加载报表失败"这样的错误,难道真的没有办法了????
    我自已单独作一个webform,也是出现"加载报表失败"这样的错误.
    究竟是什么原因呢?想头痛了还想不明白!
    两个文件如下:
    -------webform1.aspx----------<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %>
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="view.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <cr:CrystalReportViewer id="cr1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 16px"
    runat="server" Height="1163px" Width="1000px" ReportSource='<%# "C:\\Inetpub\\wwwroot\\view\\crystalreport1.rpt" %>'>
    </cr:CrystalReportViewer></FONT>
    </form>
    </body>
    </HTML>----------------------------------------
    -------------webform1.aspx.cs-------------
    using System;
    using System.Collections;
    using System.ComponentModel;using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;using CrystalDecisions.Shared ; //负责解释TableLogOnInfo类
    using CrystalDecisions.CrystalReports.Engine ;
    using System.Data.OleDb;namespace view
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    cr1.DataBind(); } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {     }
    #endregion
    }
    }
    ------------------------------------------------------错误信息如下:
    ---------------
    Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: 加载报表失败。Source Error: 
    Line 13:  <form id="Form1" method="post" runat="server">
    Line 14:  <FONT face="宋体">
    Line 15:  <cr:CrystalReportViewer id="cr1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 16px"
    Line 16:  runat="server" Height="1163px" Width="1000px" ReportSource='<%# "C:\\Inetpub\\wwwroot\\view\\crystalreport1.rpt" %>'>
    Line 17:  </cr:CrystalReportViewer></FONT>
     Source File: c:\Inetpub\wwwroot\view\WebForm1.aspx    Line: 15 Stack Trace: 
    [LoadSaveReportException: 加载报表失败。]
       CrystalDecisions.Web.ReportAgent.h() +317
       CrystalDecisions.Web.ReportAgentBase.set_ReportSource(Object value) +229
       CrystalDecisions.Web.ReportAgent.set_ReportSource(Object value) +14
       CrystalDecisions.Web.CrystalReportViewerBase.set_ReportSource(Object value) +36
       ASP.WebForm1_aspx.__DataBindingcr1(Object sender, EventArgs e) in c:\Inetpub\wwwroot\view\WebForm1.aspx:15
       System.Web.UI.Control.OnDataBinding(EventArgs e) +102
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +206
       System.Web.UI.Control.DataBind() +12
       view.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\view\webform1.aspx.cs:53
       System.Web.UI.Control.OnLoad(EventArgs e) +102
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1064 -----------------------困扰我好久的问题了,哪位大虾帮忙解决了,加 100 分!!!