我有一个水晶报告,在打开文档时给出了未定义的错误,是否有任何人遇到此类错误,下面是编码:
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等,任何线索
答案 0 :(得分:3)
所以错误实际上是“未定义的错误”?从来没见过那个。
首先猜测您需要完整的物理路径来报告。
rpDoc.Load(Server.MapPath(@"TicketingBasic.rpt"));
答案 1 :(得分:1)
你是如何处理报告的?
当我们做报告时,我们设置文件名:
ReportSource.Report.FileName = FileName;
其中filename是一个字符串,它是文件的名称(显然)。然后我们选择报告表并以任何格式导出。试试这个。