Skip to content

Printing Crystal Report

Alex

Asked Feb 26, 2009, 9:25 AM EST3 answers
Share
LinkedInX

Hello everybody,

 

I need to print existing Crystal Report from my application.  What I have:

 

Code
ReportClass myReport = new ReportClass();
myReport.FileName = “C:\…some path to the report file”;
myReport.SetDatabaseLogon(“userid”, “password”, “server”, “database”);
myReport.PrintOptions.PrinterName = “some printer”;
m_ myReport.PrintToPrinter(1, false, 0, 0);

 

Some problem appears in SetDatabaseLogon(...) function.  It returns error:

“Unable to connect: incorrect log on parameters”,

which is absolutely wrong message, because all parameters are OK. 

For debugging purpose I just hard coded “userid”, “password”, “server”, “database” while using SetDatabaseLogon function.  And without any problem  using these parameters I could login to Query Analizer or Management studio, also  I could open the report and create new connection using these “userid”, “password”, “server”…

 

Does anybody has any idea what am I missing?  What am I doing wrong?

 

Thank you in advance,

Alex

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    Did you create your report using Enterprise version or in Visual Studio? If it's in Visual Studio, you need to make sure report is added to the project is available locally. I had this problem once but it was when I created reports using CR Enterprise. But I got it resolved when I copied reports to my local project and added as an existing item.
    0
  • 0

    Thanks Mahesh for your reply, but I cannot believe it that this is the only way to display existing reports using C# Crystal Report classes.  Because my application has to show reports created independantly.  So every time new report added I have to rebuild my applicaton?  If you are right, I may have to look for another way to work with Crystal Reports.  Too bad, but I still cannot believe that this C# feature are so week.

    Anyway, I'll try to add this report to my project and see if this will solve the problem.

    Thanks again for you reply,

    Alex

    0
  • 0

    For those who might be interested I’ve solved this problem:

     

    Instead of calling SetDatabaseLogon(...) (still don’t understand why this function didn’t work) I set logon info to all tables of the report and all tables of sub reports (if any).

     

    Regards,

    Alex

    0