Solved

running a crysal report from a console application

Posted on 2008-10-29
2
526 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 70

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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