Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

c# - Crystal Report doesnt display in ASP.net webpage which is build by using VS 2013

I am developing a website using ASP.NET and I want to display a report in my webform. I am using crystal report as my reporting tool. I am using visual studio 2013 as my IDE. This what I have tried. (My SAP version is to 13.0.9).

private void loadReport()
    {
        ReportDocument rpt = new ReportDocument();
        rpt.Load("D:\Report_Test.rpt");
        rpt.VerifyDatabase();

        CrystalReportViewer1.ReportSource = rpt;

    }

above code works fine with visual studio 2010 but not in 2013. When I load the page it is empty. Not throwing any errors. so, How can view Crystal Report using Visual Studio 2013 ?.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The first thing to check,is whether the report viewer clientside files are available, I suspect that's your issue (you may find it's silently throwing a javascript error!). In IIS it should have created a virtual directory, if IIS express, then you'll need to move the files the viewer needs manually, the following should work:

Create a folder called crystalreportviewers13 folder in the root your application, copy the contents of the folder C:Program Files (x86)SAP BusinessObjectsCrystal Reports for .NET Framework 4.0CommonCrystal Reports 2011crystalreportviewers into that folder (the source path seems to vary on different machines).

Add this to the configsections of your web.config

<configSections>
<sectionGroup name="businessObjects">
  <sectionGroup name="crystalReports">
    <section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" />
    <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />
  </sectionGroup>
</sectionGroup>

Then add this into the configuration section of your web.config

<businessObjects>
<crystalReports>
  <rptBuildProvider>
    <add embedRptInResource="true" />
  </rptBuildProvider>
  <crystalReportViewer>
    <add key="ResourceUri" value="/crystalreportviewers13" />
   </crystalReportViewer>
</crystalReports>
</businessObjects>

And it should work....

I'd first download the latest version from here http://scn.sap.com/docs/DOC-7824

If it still doesn't display check your web.config is pointing at the right version. If you've still got problems, then check the doc type in your HTML declaration - as I recall it doesn't work properly with HTML5.

Edit:

In earlier versions of crystal that folder I mentioned above is automatically copied into c:inetpubwwwrootaspnet_clientsystem_web4_0_30319 - if you copy the whole aspnet_client into the root of your application that resolved the issue - in the later versions of crystal I believe that if you don't have IIS running when you install it doesn't create that folder anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...