2009-08-05 54 views
1

我有一个水晶报表打开文档时,给了我未定义的错误,没有任何一个遇到这种类型的错误,下面是编码:Crystal报表十一+ C#.NET文档加载问题

public partial class _Default : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

     ///create instance of class first 
     ReportDocument rpDoc = new ReportDocument(); 
     ///load the report 
     rpDoc.Load(@"TicketingBasic.rpt");////------->>>problem is here 

     ///pass the report to method for dataInfo 
     getDBInfo(rpDoc); 
     /// et the source for report to be displayed 
     CrystalReportViewer1.ReportSource = rpDoc; 
    } 

    protected static void getDBInfo(ReportDocument rpDoc) 
    { 
     ///Connection Onject 
     ConnectionInfo cn = new ConnectionInfo(); 
     ///DataBase,Table, and Table Logon Info 
     Database db; 
     Tables tbl; 
     TableLogOnInfo tblLOI; 

     ///Connection Declaration 
     cn.ServerName = "???????????"; 
     cn.DatabaseName = "??????????"; 
     cn.UserID = "?????????"; 
     cn.Password = "????????????"; 

     //table info getting from report 
     db = rpDoc.Database; 
     tbl = db.Tables; 

     ///for loop for all tables to be applied the connection info to 
     foreach (Table table in tbl) 
     { 
      tblLOI = table.LogOnInfo; 
      tblLOI.ConnectionInfo = cn; 
      table.ApplyLogOnInfo(tblLOI); 
      table.Location = "DBO." + table.Location.Substring(table.Location.LastIndexOf(".") + 1); 

     } 

     db.Dispose(); 
     tbl.Dispose(); 
    } 

} 

决赛代码片段是:

rpDoc.Load(Server.MapPath(@"TicketingBasic.rpt")); 

谢谢大家的帮助。

我现在遇到的问题是报告不打印或导出到其它类型,如.PDF,的.xsl,.DOC等任何线索

回答

3

所以错误字面意思是“未定义的错误”?从来没有见过这样的一个。

首先猜测是您需要报告的完整物理路径。

rpDoc.Load(Server.MapPath(@"TicketingBasic.rpt")); 

HttpServerUtility.MapPath

+0

我现在遇到的问题是报告没有打印或导出到其他类型,如.pdf,.xsl,.doc等,任何线索 – Developer 2009-08-06 16:04:17

+0

如果您在page_init中加载报告,会发生什么情况? – dotjoe 2009-08-07 02:01:55

+0

+1当接受的答案没有得到赞扬时,这个人会杀死我。最近发生在我身上的两次。 – Dusty 2009-08-13 18:17:00

1

你是如何处理的报告outout?

当我们做的报告中,我们设置文件名:

ReportSource.Report.FileName = FileName; 

其中,文件名是一个字符串,是文件(显然)的名称。然后我们选择报表并以任何格式导出。尝试这个。

+0

出口是没有问题的,因为它在报告inclided - >导出为pdf,.excel,.DOC ....,我有被打开文档 – Developer 2009-08-05 18:33:08

+0

问题我明白,这只是一个以不同方式设置报告文件的例子和想法。祝你好运! – 2009-08-06 14:58:47