我是.net开发者。在这里,我只想将CrstalReport文档路径设置为数据集。这是我的代码:
ReportDocument reportdocument = new ReportDocument();
reportdocument.SetDataSource(myDataSet);
CrystalReportViewer1.ReportSource = reportdocument;
此处在SetDataSource(myDataset)行发生错误,如:
Server Error in '/EasyWeb' Application.
Invalid report file path.
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: Invalid report file path.
Source Error:
Line 1652: }
Line 1653: myDataSet.Tables.Add(dt);
Line 1654: reportdocument.SetDataSource(myDataSet);
Line 1655: break;
Line 1656: case "Outbox":
Source File: f:\EasyWeb\EndUser\Post_History.aspx.cs Line: 1654
Stack Trace:
[LoadSaveReportException: Invalid report file path.]
CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowException(String message, EngineExceptionErrorID id) +89
CrystalDecisions.CrystalReports.Engine.ExceptionThrower.ThrowEngineException(String messageID, EngineExceptionErrorID id) +269
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +340
CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport() +175
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) +89
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet) +115
EndUser_FS_File_History.lbut_print_Click(Object sender, EventArgs e) in f:\EasyWeb\EndUser\Post_History.aspx.cs:1654
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
我在这里出错......
--------------------------------------更新----- -----------------------------------------------
这是我的LINQ代码:
var query1 = from p in db.Posts
join c in db.Categories on p.Category_id equals c.Id
join u in db.Users on p.User_id equals u.Id
where (p.ToUser_id == user_id || p.ToUser_id == null) && p.User_id != user_id && (p.group_id == group_id || p.group_id == null) && (p.status_id == int.Parse(Session["status_id"].ToString()) || p.status_id == null)
orderby p.Sent_Datetime descending
select new
{
Id = p.Id,
Title = p.Title,
Publisher = u.First_name + " " + u.Last_name,
PublishDate = p.Sent_Datetime,
IsFile = p.IsFileAttached,
CategoryName = c.Category_name,
FileSize = p.TotalFileSize
};
foreach (var item in query1)
{
if (item != null)
{
var query1_1 = from f in db.Flags
where f.Post_History_id == item.Id && f.User_id == user_id
select new
{
IsImp = f.IsImportant,
IsTrashed = f.IsTrashed,
IsRemoved = f.IsRemoved
};
bool IsIns = true;
bool IsImp = false;
foreach (var item1 in query1_1)
{
if (item1 != null)
{
if (item1.IsTrashed == true || item1.IsRemoved == true)
{
IsIns = false;
}
if (item1.IsImp != null)
{
IsImp = bool.Parse(item1.IsImp.ToString());
}
break;
}
}
if (IsIns == true)
{
DataRow dr = dt.NewRow();
dr["Id"] = item.Id.ToString();
dr["IsImp"] = IsImp;
dr["Title"] = item.Title.ToString();
dr["Publisher"] = item.Publisher.ToString();
dr["PublishDate"] = Convert.ToDateTime(item.PublishDate.ToString());
dr["IsFile"] = bool.Parse(item.IsFile.ToString());
dr["CategoryName"] = item.CategoryName.ToString();
dr["FileSize"] = item.FileSize.ToString();
dt.Rows.Add(dr);
}
}
}
myDataSet.Tables.Add(dt);
答案 0 :(得分:2)
在声明后试试。
reportdocument.Load("FilePath");
您的错误显示。
Server Error in '/EasyWeb' Application.
Invalid report file path.
表示您未指定报告路径或指定路径无效。