Using Crystal Report XI in Visual Studion 2008

AnandSahoo
AnandSahoo used Ask the Experts™
on
Hi Team,

Facing little problem in integrating crystal report with asp.net.

I have a windows 2008 R2 server.
Visual Studio 2008 professional edition installed which support Crystal Report.
I also have Crystal Report XI software installed separately.

I used to develope crystal report using crystal report software separately, not in vs2008.where parameter in record selection is like
{open_date} >= {?startdate} and {open_date} <= {?end_date}

Below is my code to display a parameter based crystal report in web page.

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace MISC.Reports
{
    public partial class Reopen_report : System.Web.UI.Page
    {
        protected void Page_load(object sender, EventArgs e)
        {
            ReportDocument report = new ReportDocument();
            report.Load("D:\\Reports\\Reopen_Tickets.rpt");
            report.SetDatabaseLogon("user", "password");            
            Reopen_Report.ReportSource = report;
            Reopen_Report.RefreshReport();
        }

Problems I am facing:-

1. While loading in webpage,it shows the parameter screen first. After parameter input it is very very slow. When I use Crystal report software and use the same report it is faster.

Solutions tried -

        Added Reportsource ID
        Uninstalled crystal XI software

But still the same issue
       


2. The report shows the data after 3 to 4 minutes. After that when I try any action on the crystal toolbar like export,print,next page etc ( Important is export), It is doing a post back and coming back toparameter screen again. Report disappears.

Solution Tried :-
      changed the page_load to page_init  --  After that it does not show the export pop up at all. It is like loading loading and done.

     Added postback code as below both using page_load and page_init and Session variable.

protected void Page_load(object sender, EventArgs e)
        {
if(!page.ispostback)
{
            ReportDocument report = new ReportDocument();
            report.Load("D:\\Reports\\Reopen_Tickets.rpt");
            report.SetDatabaseLogon("user", "password");  
           Session.Add("report1",report);        
            Reopen_Report.ReportSource = report;
            Reopen_Report.RefreshReport();
        }
else
{
Reopen_Report.ReportSource = Session["report1"];
            Reopen_Report.RefreshReport();
}
}

But still the same issue.

Can you help me to resolve these 2 issues please ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
You don't want to refresh the report.  Doing that, Crystal assumes you want to prompt for new parameters.

mlmcc

Author

Commented:
Are you saying we should not put this line at all in the code

Reopen_Report.RefreshReport();
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
That is what I am saying.

You can use it when you first open the report or save the report without data and it will automatically refresh when opened.

mlmcc
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Author

Commented:
Hi mlmcc,

i have removed the refresh from else part of code. It is only there in postback now.
Looks like toolbar issue while export,print,next is happening quickly now without reloading again.

But the first loading is still slow. When i run the report in crystal software it takes few seconds,but in webpage it takes more than 3 mins.

Can you please explain the 2nd line of yours in details. How to save it and load it? Because it has date as parameter and if parameter changes it has to reload fresh again.
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
WHen you run the report the first time you need to prompt for parameters.  Doing a refresh will force that.  Crystal defaults to SAVE DATA WITH REPORT as the save option.  You can turn that off and the report will save with no data thus when run it will require the prompting of parameters.

That may also speed the initial load.

When run from the web server, do you have a default printer defined?  Crystal looks for the printer it was built with and can take some time to discover the printer is not available.
You can set the report to use NO PRINTER.

Are you running against the same database?

mlmcc

Author

Commented:
Yes i am running the report against the same database. Its oracle 10 and odbc of which is installed on the web server.
How do i set as no printer. Is it the bottom option in page setup. I am using crystal xiv
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Yes.

mlmcc

Author

Commented:
Thank You So much.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial