Link to home
Start Free TrialLog in
Avatar of vss-pt
vss-ptFlag for Portugal

asked on

ReportDocument take a log time to load

If the production database is different from the development database loading the report take more then two minutes.
Is the a way to avoid this issue.
The code to print the report is the following....
Cursor.Current = Cursors.WaitCursor;
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = m_ServerName;
connectionInfo.DatabaseName = m_DatabaseName;
connectionInfo.UserID = m_UserID;
connectionInfo.Password = m_Password;
connectionInfo.IntegratedSecurity = false;
   
ReportDocument myReport = new ReportDocument();

myReport.FileName = reportPath;
myReport.SetDatabaseLogon(m_UserID, m_Password);
            
myReport.Load(reportPath); // takes about two minutes

SetDBConnectionForReport(connectionInfo, myReport);
SetDBConnectionForSubreports(connectionInfo, myReport);

CRPrint.ReportSource = myReport;
CRPrint.SelectionFormula = selFormula;
CRPrint.RefreshReport();
if (printerName == string.Empty)
{
    Cursor.Current = Cursors.Default;
    PrintDialog dlg = new PrintDialog();
    dlg.ShowDialog();
    Cursor.Current = Cursors.WaitCursor;
    myReport.PrintOptions.PrinterName=
        dlg.PrinterSettings.PrinterName;
    printerName = myReport.PrintOptions.PrinterName;
}
myReport.PrintToPrinter(1,false,1,1);
Cursor.Current = Cursors.Default;

Open in new window

Avatar of Mike McCracken
Mike McCracken

I would check to see if the same printer is available on both systems.  I find when I get foreign reports they take a long time to load and then I get an PRINTER message saying the printer the report was developed with is not available and the default printer will be used.  In general I never have the database available.

These are reports users upload here so I don't expect to have the database.

mlmcc
Crystal 2008 just seems to take a very long time to switch the data to different databases. We have speeded up some necessary reports by converting the data source to a command, meaning it only has one 'table' to switch databases, but there was a significant drop in loading speed between Crystal XI and Crystal 2008.
You can save the production report with the production connection and you will avoid crystal reports to verify the database each time you switch the connections. You will still need to set database connection , but this will be just to set the user and password. However loading is before SetDBConnectionForReport so your problem is somewhere else. 2 minutes is too big period . It looks like timeout to me.  It can be a missing printer, mapped drive or a connection issue.
Are you running the report on the same machine where test world report is working fine?
Avatar of vss-pt

ASKER

By changing the database to the production on Crystal Reports solves the problem, but still if the client changes teh database name or server location the problem persists

The mais issue is that the same report is used in diferente Servers / databases. It's anoying tho produce one for each server /database.

It seem that on Load it check´s the database connection, before I have the chance to change it.

I have seen some 'load' event preapps is there the correct place to change logon parametes?
Is there an OPEN method on the report document?
I believe LOAD tries to run the report where as OPEN just opens the report for modifications like you want to do?

myReport.OPEN(reportPath);

Why do you do a REFRESH?
If you are always going to do a refresh, you could simply not save the report with data and the report will automatically load the newest data.

mlmcc
Do you have option "Save data with report" checked (in Report options) ?
Avatar of vss-pt

ASKER

No I don't wave the option 'save data with report' and there is no 'open' method available.
I have addes thsin tow lines with no efect.

            myReport.FileName = reportPath;
            myReport.SetDatabaseLogon(m_UserID, m_Password, m_Database);
            myReport.Load(reportPath);
 There is a EnterpriseSession method, what is it for?
Avatar of vss-pt

ASKER

That is what I'm doing.
The main isue is the load method.
It take abou 2 minut's to realize the database is not available.
I don't see the LOAD used in the sample

mlmcc
vss-pt, obviously the report is trying to connect to the database on load. Any chance to upload the report here ?
If you cannot upload then:
 - What is the version of this report ? I have seen some crystal 8 -8.5 reports with integrated security which were trying to connect to the initial database no matter what you are doing. What is your login type ?
 - Do you use command ?
 - Do you have dynamic value list ?
Avatar of vss-pt

ASKER

mlmcc:
The load method is the line in samples...
cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
...
vasto:
I don't have the final release on hand, but this repçort prodices the same efect.


APL-Frente.rpt
Avatar of vss-pt

ASKER

vasto:
Do you need more info?
vss-pt, I will check the report. Thanks!
Avatar of vss-pt

ASKER

I think the problem is not report related, but with the Crystal API for VS 2005.
But still if you have any ideas. For now I have created a copy of the report for each database,
I know it doesn´t make any sense but I cant have the use waitin 2 minutes to print a card.
vss-pt , something is messed up with the database information.
We have a tool which is changing the datasource to fix issues like this. Please check the report and let me know if it is fixed now. APL-Frente.rpt
Avatar of vss-pt

ASKER

vasto:
Yes in fact loadreport executes imediatly, but setting server/database/user/password wont prevent login box to be displayed.
On the login box, the database is blank so we cannot even manualy logon.
But still this is the way to solve the problem

Two questions, the first one is what product do you use to 'fix' the report? Also what version is the report on?




ASKER CERTIFIED SOLUTION
Avatar of vasto
vasto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vss-pt

ASKER

Partial solution, But a very good lead.