473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exporting Crystal Report in PDF on server side

Dear folks,

I was trying to write a .Net web application (using C#) that loads a
Crystal
Report on server side, export the report in PDF format as a file in
the web
server, and then serves up the file for clients to download. My code
was
working so far so good until I added ONE line.

Here's my working code so far:

---------------- (code start) -------------------------
System.Diagnostics.EventLog EventLog1 = new
System.Diagnostics.EventLog();

try
{
DiskFileDestinationOptions dFileDOpts = new
DiskFileDestinationOptions();

//string sSrcPath = this.MapPath("./BigReportTest.rpt");
string sSrcPath = this.MapPath("./2003_07_08_DLOTable.rpt");
//string sSrcPath = this.MapPath("./Sample_Report.rpt");

// Generate unique name for output file
StringBuilder sFileName = new
StringBuilder(DateTime.Now.ToShortDateString() + "_" +
DateTime.Now.ToShortTimeString() + "_" +
DateTime.Now.Millisecond.ToString());

sFileName.Replace(" ", "_");
sFileName.Replace(":", "_");
sFileName.Replace("/", "_");

string sResultFileName = sFileName.ToString();
string sDesPath = this.MapPath("./CRResult/" + sResultFileName +
"_BigFile.pdf");
ReportDocument oRD = new ReportDocument();
oRD.Load(sSrcPath);

dFileDOpts.DiskFileName = sDesPath;

ExportOptions eOpts = new ExportOptions();
eOpts = oRD.ExportOptions;
eOpts.ExportDestinationType = ExportDestinationType.DiskFile;
eOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
eOpts.DestinationOptions = dFileDOpts;

oRD.Export();
oRD.Close();

if (!System.Diagnostics.EventLog.SourceExists("MyApp1 "))
System.Diagnostics.EventLog.CreateEventSource(
"MyApp1", "Application");
EventLog1.Source = "MyApp";
EventLog1.WriteEntry ("Crystal Report pdf export success.");

}
catch(Exception fu)
{
if (!System.Diagnostics.EventLog.SourceExists("MyApp1 "))
System.Diagnostics.EventLog.CreateEventSource(
"MyApp1", "Application");
EventLog1.Source = "MyApp";
EventLog1.WriteEntry ("Something wrong with Crystal Report Load
Test!" + fu.Message);
};

---------------- (code end) -------------------------

After running, I got a pdf file in the CRResult folder. So far so
good. But
the report was NOT UPDATED to the latest change in the database. So I
added one
line to do REfresh:

.......
oRD.Load(sSrcPath);
oRD.Refresh(); // This is what I added
.......

Well, I got an error on the "oRD.Export()" line after at:

"Query Engine Error on line xxxxx"
So what did I do wrong? Is there any other way to get the refresh
view of the
report. And how come the data was not automatically pull form
database?

BTW, the report contains simply the content of a database table in a
Oracle 9i
Release 2 database. Maybe I don't need to a refresh if I reference to
a Stored
Procedure instead of pointing to a database table directly?

Any suggestions are welcomed. Thanks!!
Deecay
Jul 19 '05 #1
1 8516
Deecay,

If you save the data with your report, Crystal will not refresh the data if the parameters supplied are the same, unless you add the .refresh() method call, as you did. If you edit your report, unchecking the "save data with report" option, and remove the .refresh() method call, chances are you will get the same error when running the export. Do you have more specifics on the Query Engine error? Does it specify the problem, such as "Logon Failure"?
Jul 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DeeCay | last post by:
Dear folks, I was trying to write a .Net web application (using C#) that loads a Crystal Report on server side, export the report in PDF format as a file in the web server, and then serves up...
1
by: Lasso | last post by:
Hi all, Im having problem in exporting pdf file from crystal report. Now I already can show the crystal report but error when exporting. this is my code: Dim myReport As USERReport = New...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
1
by: warlord | last post by:
In order to save typing, I've borrowed the text from a post of nearly 12 months ago.....but the problem still exists. I've been banging my head all day with this, so I'm hoping someone has some...
0
by: adamz5 | last post by:
I am currently exporting a crystal report using code. This works fine and exports the report to a word document onto disk using DiskFileDestinationOptions() and ExportOptions However when i...
4
by: BizWorld | last post by:
I am getting this error in exporting a crystal report (having two subreports) using C# code. i got the following exception at Export statement. Exception Details:...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
2
by: microsoft . public . sqlserver | last post by:
I am a Web developer. I am new to VB 6.0 and Crystal Report. I have joined an organisation where there is an application running(developed in VB6 and crystal report 7). I have to modify one report....
0
by: mabubakarpk | last post by:
Hi every one I am facing problem (VB6.0 + Crystal report) while exporting crystal report in VB6.0 it return message "Invalid Directory" while it 100% work on another computer dim rpt as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.