简体   繁体   中英

Crystal Report Load Report Failed in VS2010

I trying to create an application in c# with Crystal Report and then I create setup file using publish wizard and delivery to my client.

Now I use following code to bind crystal report in c#.

          ReportDocument doc = new ReportDocument();
          doc.Load("D//CrystalReport1.rpt",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);

            doc.SetDataSource(dt);
            crystalReportViewer1.ReportSource = doc;
            crystalReportViewer1.Refresh();

At client Side generate following error.

错误生成快照

'Load report failed.' exception occurs when the path specified for the .rpt file is incorrect. Please check the file path again. Also try the below code.

When working for web

doc.Load(Server.MapPath("\\CrystalReport1.rpt")",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

Prefer to put the .rpt file in a folder and also specify the folder location.For eg.

Make a Folder Reports inside solution and consolidate all the .rpt files inside the folder

doc.Load(Server.MapPath("\\Reports\\CrystalReport1.rpt")",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

When working for window

doc.Load(@"D//CrystalReport1.rpt",CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

trying using with a sign '@'. Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM