Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Business Objects: Crystal Reports 2 Data Access FAQ

Connection Problems

Push model with a manually populated Dataset? Export to PDF? by aftertaf
Posted: 17 Jun 04

After pulling out my hair for days on end, i am finally getting round to using Crystal reports for .NET with satisfactory results...

the PDF export problem is sorted


public void DoPDF(System.Web.SessionState.HttpSessionState httpSess, System.Web.HttpRequest httpreq, System.Web.UI.Page httpPage, ref CrystalDecisions.CrystalReports.Engine.ReportDocument myReport) {
            HttpResponse httpresp = httpPage.Response;
            ExportOptions Export;
            DiskFileDestinationOptions tempFileOptions;
            string tempFilename;
            tempFilename = "c:\\TEMP\\" + httpSess.SessionID.ToString() + ".pdf";
            tempFileOptions = new DiskFileDestinationOptions();
            tempFileOptions.DiskFileName = tempFilename;
            Export = myReport.ExportOptions;
            Export.DestinationOptions = tempFileOptions;
            Export.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
            Export.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;


            httpresp.ContentType = "application/pdf";


stick this code in a new class and call it...


reporting posteReport = new reporting();
posteReport.DoPDF(Session, Request, Page, ref myReport);

that way any page and any ReportDocument can be exported to PDF with very litte extra effort

don't forget to repopulate the data as well before calling the ExportPDF code...

and for the Push Model... up until now i've been using the Pull model with SQL Server 2000, but since i have Stored procedures with 15 parameters and seeing as CR.NET hates it when a report is linked to a Stored Procedure that has logic and if clauses, throwing all sorts of errors... i decided to go with the Push model.

Four steps to do:
-define a dataset file (CR gets its field references here)
-build the report using dataset file as source
(dataset file can then be deleted.....)
___run time____
-fill a dataset object in the code (which creates a datatable within the dataset)
-associate the report to the dataset object

it all works well, until Boom!, run time gives you a nice Engine Exception : Query Error of some kind (don't have the exact term, using a french version)

the trick is, give the dataset a name...
and also give this same name to the datatable you create in step 3.

and the ABSOLUTE MUST for help (seeing as there is little to no doc around)
a free, complete book on CR for .NET

Back to Business Objects: Crystal Reports 2 Data Access FAQ Index
Back to Business Objects: Crystal Reports 2 Data Access Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close