Solved

running a crysal report from a console application

Posted on 2008-10-29
2
523 Views
Last Modified: 2012-06-27
Hi,  I am working on a console application that has a crystal report attached to it as part of its project.  I am trying to find a way to trigger the report from within the console application and output the report to a file to be used later.  The report is connected to a SQL database table on a remote server.  The code that I have been attempting to use so far is just&

       ReportDocument billrpt = new ReportDocument();
       rpt.Load("~/Report.rpt");

When it runs I get a load report failed error.  I am assuming there has to be more to setting this up.

Thanks.
0
Comment
Question by:mike8758
2 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 22834600
The ~ is used in web applications to return to the root. It has no meaning in Windows/Console application.
0
 

Author Comment

by:mike8758
ID: 22841615
I wanted to add a little clification to this item because even though emoreau pointed out my problem the total solution was not reported.

This turned out to be much easier then I had though

In my console application I ran the following snipet&

ReportDocument rpt = new ReportDocument();
string apppath = Application.StartupPath.ToString() + "\\Report.rpt";
rpt.Load(apppath);
rpt.SetDatabaseLogon("user","password");
rpt.ExportToDisk(ExportFormatType.PortableDocFormat, c:\\testreport.pdf");

Now some things to keep in mind&
1:  In my case my report was an added item to my console application project.
2:  And my (crystal) report was set up to use dedicated database tables that are loaded by my console app earlier in the process.  
     
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now