Crystal reports 如何在asp.net 3.5中将CrystalReport文档路径设置为数据集

Crystal reports 如何在asp.net 3.5中将CrystalReport文档路径设置为数据集,crystal-reports,asp.net-3.5,Crystal Reports,Asp.net 3.5,我是.net开发者。这里我只想将CrstalReport文档路径设置为Dataset。这是我的代码: ReportDocument reportdocument = new ReportDocument(); reportdocument.SetDataSource(myDataSet); CrystalReportViewer1.ReportSource = reportdocument; 在SetDataSource(myDataset)行出现以下错误: Server Error i

我是.net开发者。这里我只想将CrstalReport文档路径设置为Dataset。这是我的代码:

 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);

在声明之后尝试这个

reportdocument.Load("FilePath");
您的错误显示

Server Error in '/EasyWeb' Application.
Invalid report file path.

表示您没有指定报告路径或给定的路径无效。

我只想使用数据集筛选此记录,但如何在不定义报告路径或创建报告对象的情况下显示报告。好的。这对我很有帮助。这里我只想用LINQ查询过滤记录,并将结果存储在数据集中。是将DataSource设置为Dataset的方法。Dataset是DataTable的集合。当您试图在SetDataSource中分配dataset时,这意味着dataset中包含的表必须存在于已创建的报表中。能否将LINQ查询代码放置在数据集已填充的位置。好的,将表名设置为与crystal报表中包含的表相同
dt.TableName='TableName'
myDataSet.Tables.Add(dt)之前。这将用于将crystal report中的表映射到dataset。