Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

running a crysal report from a console application

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 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