当前位置:编程学习 > C#/ASP.NET >>

水晶报表找不到指定文件

近日在做水晶报表,在本地运行可以,可是传到服务器上就不行了,说找不到指定文件,是怎么回事啊,服务器端的水晶报表已经注册过了,还是不行,望高手解决, --------------------编程问答-------------------- 你是ASP.NET吗?路径要加上Server.MapPath --------------------编程问答-------------------- 把详细的报错位置,报错信息贴出来看看

找不到文件是找不到rpt模板文件还是依赖组件? --------------------编程问答-------------------- 详细的错误如下
[COMException (0x80004005): 系统找不到指定的文件。
]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +87
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +279

[Exception: Load report failed.]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +340
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +870
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +73
   WebApplication2.reports.CrystalReport21.Page_Load(Object sender, EventArgs e) in E:\c#programing\webapplication\sourcesafe\WebApplication2\reports\CrystalReport2.aspx.cs:32
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------编程问答-------------------- CrystalReport2.aspx.cs

这个文件的代码贴出来,可能真如1楼所说 --------------------编程问答--------------------  string strsql = "SELECT TASK_NAME,TASK_START_DATE,TASK_FINISH_DATE FROM MSP_TASKS WHERE PROJ_ID='"+ProjectID+"' AND TASK_ID>0";
            DataTable table = mybase.SQLQuery(strsql);
            //设置加载路径,此路径为绝对路径
            string path1 = Server.MapPath("~\\reports\\");
            string path2 = path1 + "CrystalReport2.rpt";
            ReportDocument rpt = new ReportDocument();
            rpt.Load(path2);
            //rpt.Load(Server.MapPath("CrystalReport2.rpt"));
            rpt.SetDatabaseLogon("baosteel", "12345");
            rpt.SetDataSource(table);
            CrystalReportViewer1.ReportSource = rpt; --------------------编程问答-------------------- 你把path2 写出来看看是啥,这个路径是真是存在的吗?

如果确实存在,把IIS重启一下再看。
--------------------编程问答-------------------- 帮顶. --------------------编程问答-------------------- path2 是真实存在的路径, --------------------编程问答-------------------- --------------------编程问答-------------------- 楼上说的对,路径要加上Server.MapPath
补充:.NET技术 ,  图表区
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,