Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
| Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2003, 09:27 PM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Refresh causing Query Engine Error

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Engine Error jjshah Crystal Reports 5 December 8th, 2005 08:56 PM
Query Engine Error .... verdun Crystal Reports 6 February 7th, 2005 03:42 AM
Query Engine Error khanhpnd .NET Web Services 2 October 6th, 2004 05:29 AM
query engine error shanzhu Crystal Reports 1 September 30th, 2004 01:13 AM
Query Engine Error AniFu .NET Web Services 0 June 18th, 2004 02:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.