469,926 Members | 2,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Exporting Crystal Report in PDF on server side

Dear folks,

I was trying to write a .Net web application (using C#) that loads a
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
working so far so good until I added ONE line.

Here's my working code so far:

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

DiskFileDestinationOptions dFileDOpts = new

//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() + "_" +

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

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

dFileDOpts.DiskFileName = sDesPath;

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


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

catch(Exception fu)
if (!System.Diagnostics.EventLog.SourceExists("MyApp1 "))
"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.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

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!!
Jul 19 '05 #1
1 7499

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mustufa Baig | last post: by
2 posts views Thread by microsoft . public . sqlserver | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.