Hello,

I have been trying to export a Crystal Report to a PDF file and keep getting the same error message. I have done many suggestions I have found on the web, but none of them worked for me.

My error message says: Logon Failed.

this is my code: (I am working with VS.NET 2003) and my report uses a Data Set Object that is on the form.

Code:

 Private Sub btnExportCompleteReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportCompleteReport.Click


        Try
            'Begin Export
            Dim crReportDocument As ReportDocument
            Dim crExportOptions As ExportOptions
            Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

            Dim exportFilePath As String = "C:\" + Format(Now, "yyMMdd") + ".pdf"

            If Dir(exportFilePath) <> "" Then
                Kill(exportFilePath)
            End If

            'Create an instance of the Chart report
            crReportDocument = New rptReportDS

            ''Set the options for saving the exported file to disk
            crDiskFileDestinationOptions = New DiskFileDestinationOptions
            crDiskFileDestinationOptions.DiskFileName = exportFilePath

            'Set the exporting information
            crExportOptions = crReportDocument.ExportOptions
            With crExportOptions
                .DestinationOptions = crDiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With



            Dim rpt As New rptReportDS  'Nombre del Reporte.
            Dim myConnection As SqlClient.SqlConnection
            Dim MyCommand As New SqlClient.SqlCommand
            Dim myDA As New SqlClient.SqlDataAdapter
            Dim myDS As New DataSet1
            '  Me.daHistPorFechas.SelectCommand.Parameters("@Fecha1").Value = Fecha1


            Try
                myDA.SelectCommand = MyCommand
                Me.SqlDataAdapter1.Fill(Me.DataSet11) ' Llena el Reporte.
                rpt.SetDataSource(Me.DataSet11)
               
            Catch Excep As Exception

                MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End Try




            'Export the report
            crReportDocument.SetDatabaseLogon("ACHReader", "ACHReader")
            ' crReportDocument.SetParameterValue("@CompanyName", CompanyName)


            Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
            crLogonInfo = crReportDocument.Database.Tables(0).LogOnInfo
            crLogonInfo.ConnectionInfo.ServerName = "Gdb03sql"
            crLogonInfo.ConnectionInfo.UserID = "ACHReader"
            crLogonInfo.ConnectionInfo.Password = "ACHreader"
            crLogonInfo.ConnectionInfo.DatabaseName = "ACHReader"
            crReportDocument.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)


            crReportDocument.Export()


        Catch ex As CrystalDecisions.CrystalReports.Engine.LogOnException

            MessageBox.Show(ex.ToString)

        End Try




    End Sub


Thanks for any suggestion, corrections, or examples...


Ed.