Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting PDF in VB.Net App

Status
Not open for further replies.

NervousRex

Programmer
Sep 4, 2003
66
0
0
US
I created a small .exe that runs nightly and exports a crystal report as .pdf files. Untill recently (2 weeks) ago, it ran fine for many months (11+), now it is erroring occasionly on the Report.Export() call.

Source: CrystalDecisions.CrystalReports.Engine
Message: Logon Failed.

I've done a bunch of searches, but not finding the solution I need, am hoping someone might be able to help me find the right one.

No passwords or login info has changed for the database and the report hasn't been touched since it was created. If you need any more info ask. Thanks

Here is the code:

Code:
        Dim Report = New CrystalDecisions.CrystalReports.Engine.ReportDocument

        ' CRYSTAL EXPORT VARIABLES
        Dim CrExportOptions As ExportOptions
        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions
        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
        Dim CrExcelFormatTypeOptions As New ExcelFormatOptions
        Dim CrHTMLFormatTypeOptions As New HTMLFormatOptions

        Try

            ' LOAD THE REPORTS
            Report.load(Report_Location)
            Report.refresh()

            ' EXPORT THE CALENDAR TO DISK
            If Export = True Then
                If Trim(Export_Extension) <> "" Then
                    CrDiskFileDestinationOptions.DiskFileName = Save_Location & "ma_" & Format(Now, "MMddyyyy") & Export_Extension
                Else
                    CrDiskFileDestinationOptions.DiskFileName = Save_Location & "ma_" & Format(Now, "MMddyyyy") & ".pdf"
                End If

                CrExportOptions = Report.ExportOptions

                With CrExportOptions
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    Select Case Export_Extension
                        Case ".pdf"
                            .ExportFormatType = ExportFormatType.PortableDocFormat
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrFormatTypeOptions
                        Case ".doc"
                            .ExportFormatType = ExportFormatType.WordForWindows
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrFormatTypeOptions
                        Case ".rpt"
                            .ExportFormatType = ExportFormatType.CrystalReport
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrFormatTypeOptions
                        Case ".xls"
                            .ExportFormatType = ExportFormatType.Excel
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrExcelFormatTypeOptions
                        Case ".html", ".htm"
                            .ExportFormatType = ExportFormatType.HTML40
                            CrHTMLFormatTypeOptions.HTMLBaseFolderName = Save_Location
                            CrHTMLFormatTypeOptions.HTMLFileName = "ma_" & Format(Now, "MMddyyyy") & Export_Extension
                            CrHTMLFormatTypeOptions.HTMLEnableSeparatedPages = False
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrHTMLFormatTypeOptions
                        Case Else
                            ' DEFAULTS TO .PDF
                            .ExportFormatType = ExportFormatType.PortableDocFormat
                            .DestinationOptions = CrDiskFileDestinationOptions
                            .FormatOptions = CrFormatTypeOptions
                    End Select

                End With

                Report.Export()
            End If

            If Print = True And Trim(Printer) <> "" Then
                Report.PrintOptions.PrinterName = Printer
                Report.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
                Report.PrintToPrinter(1, True, 0, 0)
            End If

        Catch ExceptionMessage As System.Exception
            email_Status("An error occured while exporting the MA_Calendars " & ExceptionMessage.Message)
        Finally
            Report.close()
            Report.dispose()
            Report = Nothing
            CrExportOptions = Nothing
            CrDiskFileDestinationOptions = Nothing
            CrFormatTypeOptions = Nothing
            CrExcelFormatTypeOptions = Nothing
            CrHTMLFormatTypeOptions = Nothing
        End Try
 
Did the DBA change the user permission and/or password two weeks ago? I would look at that first.
~Brett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top