我使用的是Windows XP SP3,Crystal Reports Basic版本10.5.3700.0(后跟c:\ windows \ assembly),Visual Studio 2008,MSSQL 2008 R2。
错误
文件C中的错误:\ DOCUME~1 \ NKT \ LOCALS~1 \ Temp \ Bill {CE9EC584-2281} .rpt:
错误说明
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中的起源位置的更多信息。
异常详细信息:
System.Runtime.InteropServices.COMException: Error in File C:\DOCUME~1\NKT\LOCALS~1\Temp\Bill
{CE9EC584-2281-4C5F-89ED-54C60AFCC0CB}.rpt:
The table could not be found.
来源错误:
Line 2697: myReportDocument.SetDataSource(ds); Line
2698: //myReportDocument.PrintToPrinter(1, true,0,0);
Line 2699: myReportDocument.PrintToPrinter(1, false, 0, 0);
Source File: c:\Documents and Settings\NKT\My Documents\Visual
Studio 2008\Projects\\ParlerBill.aspx.cs Line: 2699
这是我的.cs文件代码段
//--Opening Sql Connection
String strConn = ConfigurationManager.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(strConn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(strCmd, sqlConn);
sqlConn.Open();
//--this statement is very important, here the table name should match with the XML Schema table name.
da.Fill(ds, "customerbilldetail");
//--Closing Sql Connection
sqlConn.Close();
//--(Optional) I have used it to disable the properties
CrystalReportViewer1.Visible = true;
CrystalReportViewer1.DisplayGroupTree = false;
CrystalReportViewer1.HasCrystalLogo = false;
//--Initializing CrystalReport
ReportDocument myReportDocument;
myReportDocument = new ReportDocument();
myReportDocument.Load(Server.MapPath("~//Repport/Bill.rpt"));
myReportDocument.SetDatabaseLogon("sa", "saa");
myReportDocument.SetDataSource(ds);
//myReportDocument.PrintToPrinter(1, true,0,0);
myReportDocument.PrintToPrinter(1, false, 0, 0);
错误在于抛出。