Crystal Reports export to PDF in VB.NET 
Author Message
 Crystal Reports export to PDF in VB.NET

Having a problem exporting via Crystal Reports to a PDF File.

I'm using CR v8.0, and the Crystal Reports.net that comes with visual
studio.net (It's not 8.0; higher - probably v9.0).

We've developed a standard "pull" rpt using CR v8.0 (outside of .NET)
and the code (shown below) will export, no problem. However, we wish
to be able to override the datasource the rpt will use ("push") by
passing in a new dataset via the .setdatasource method of the untyped
report document.

No error results, but the ORIGINAL datasource associated with the
design report is what is used. the .setdatasource command is
ignored/not used.

here's the code: anyone have any ideas? I've spent hours searching the
web/boards for similar issues, but haven't found any yet:

        Dim RptEngine As ReportDocument = New ReportDocument()
        Dim ds As DataSet = New DataSet()
        Dim oleConn As New System.Data.SqlClient.SqlConnection("Data
Source=SOMESQLSERVER;Initial Catalog=AuditProbe;uid=sa;pwd=;")

        Dim oleAdapter As New System.Data.SqlClient.SqlDataAdapter()
        Dim ro As ReportObjects
        Dim grp As GroupNameFieldDefinitions

        'select data from new source
        oleAdapter.SelectCommand = New
System.Data.SqlClient.SqlCommand("Select * From CO4_Report18Print",
oleConn)

        'fill data using tablename the rpt file was designed with
        oleAdapter.Fill(ds, "CO4_Report17Print")

        RptEngine.Load("Y:\Development\TestApp\RRS_TEST01.rpt")
        RptEngine.SetDataSource(ds)

        Dim diskOpts As New [Shared].DiskFileDestinationOptions()
        RptEngine.ExportOptions.ExportFormatType =
[Shared].ExportFormatType.PortableDocFormat
        RptEngine.ExportOptions.ExportDestinationType =
[Shared].ExportDestinationType.DiskFile
        diskOpts.DiskFileName = "C:\rpt1.pdf"
        RptEngine.ExportOptions.DestinationOptions = diskOpts
        RptEngine.Export()
        RptEngine.Close()
        RptEngine = Nothing

Any help would be appreciated.



Mon, 14 Feb 2005 22:55:49 GMT  
 Crystal Reports export to PDF in VB.NET
Very minor thing...not sure if it would affect it or not, but perhaps
setting the datasource before you load the report?

Jim


Quote:
> Having a problem exporting via Crystal Reports to a PDF File.

> I'm using CR v8.0, and the Crystal Reports.net that comes with visual
> studio.net (It's not 8.0; higher - probably v9.0).

> We've developed a standard "pull" rpt using CR v8.0 (outside of .NET)
> and the code (shown below) will export, no problem. However, we wish
> to be able to override the datasource the rpt will use ("push") by
> passing in a new dataset via the .setdatasource method of the untyped
> report document.

> No error results, but the ORIGINAL datasource associated with the
> design report is what is used. the .setdatasource command is
> ignored/not used.

> here's the code: anyone have any ideas? I've spent hours searching the
> web/boards for similar issues, but haven't found any yet:

>         Dim RptEngine As ReportDocument = New ReportDocument()
>         Dim ds As DataSet = New DataSet()
>         Dim oleConn As New System.Data.SqlClient.SqlConnection("Data
> Source=SOMESQLSERVER;Initial Catalog=AuditProbe;uid=sa;pwd=;")

>         Dim oleAdapter As New System.Data.SqlClient.SqlDataAdapter()
>         Dim ro As ReportObjects
>         Dim grp As GroupNameFieldDefinitions

>         'select data from new source
>         oleAdapter.SelectCommand = New
> System.Data.SqlClient.SqlCommand("Select * From CO4_Report18Print",
> oleConn)

>         'fill data using tablename the rpt file was designed with
>         oleAdapter.Fill(ds, "CO4_Report17Print")

>         RptEngine.Load("Y:\Development\TestApp\RRS_TEST01.rpt")
>         RptEngine.SetDataSource(ds)

>         Dim diskOpts As New [Shared].DiskFileDestinationOptions()
>         RptEngine.ExportOptions.ExportFormatType =
> [Shared].ExportFormatType.PortableDocFormat
>         RptEngine.ExportOptions.ExportDestinationType =
> [Shared].ExportDestinationType.DiskFile
>         diskOpts.DiskFileName = "C:\rpt1.pdf"
>         RptEngine.ExportOptions.DestinationOptions = diskOpts
>         RptEngine.Export()
>         RptEngine.Close()
>         RptEngine = Nothing

> Any help would be appreciated.



Tue, 15 Feb 2005 01:32:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Barcodes, Export to PDF, Crystal Reports .NET, WASP

2. Problem with PDF export from the Report Viewer in VB.net

3. Export PDF doesn't works after RTF export (VB.NET)

4. Crystal Reports 8.5 (VB6) to Crystal Reports NET (VB.NET) conversion

5. Exporting Crystal Report 85 to PDF from Visual Studio 6.0

6. Crystal Reports 8.5 PDF Export

7. Problem exporting PDF Files with Crystal Report 8.5

8. export crystal enterprise report in vb.net from web

9. Problem using Crystal Report 8.5 to export PDF in Visual Basic 6.0

10. after pdf Export with Crystal - pdf File isn't able to use default Font

11. Crystal Reports and exporting to PDF

12. How to export a parameterized crystal report to pdf format file

 

 
Powered by phpBB® Forum Software