Solved

running a crysal report from a console application

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

17 Experts available now in Live!

Get 1:1 Help Now