Solved

CrystalDecisions.CrystalReports.Engine.LogOnException: Logon Failed

Posted on 2004-04-02
3
3,134 Views
Last Modified: 2012-06-21
I am attempting to refresh a crystal report and then export it to a new location via a console application. I can get everything to work fine except for my refresh. If I comment out myreport.refresh() it exports just fine. So, my problem is getting this exception when I try to refresh. I have blanked out my server name , user id, and passwords for this post. They are populated and work fine when logging into sql plus from the same machine this code is being run from. I am however leaving the databasename="" because this is not required when connecting to oracle.
  I have listed what I think is important for this error. Please let me know if you need additional information.

APP Type:
Console Application

DATABASE:
Oracle

EXCEPTION:
CrystalDecisions.CrystalReports.Engine.LogOnException:Logon Failed

CODE:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared


Module Module1
    Private myreport As CrystalDecisions.CrystalReports.Engine.ReportDocument

    Sub Main()

        Dim crParameterValues As ParameterValues
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition


        myreport = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
        myreport.Load("c:\test1.rpt", OpenReportMethod.OpenReportByTempCopy)

        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
        Try
            For Each tbCurrent In myreport.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = "xxxxx"
                    .UserID = "xxxxx"
                    .Password = "xxxxx#"
                    .DatabaseName = ""
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent
        Catch Exp As LoadSaveReportException
            MsgBox("Incorrect path for loading report.", MsgBoxStyle.Critical, "Load Report Error")
        Catch Exp As Exception
            MsgBox(Exp.Message & "   in GetReportConnection Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
        myreport.Refresh()


        Dim CrExportOptions As ExportOptions
        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()

        CrDiskFileDestinationOptions.DiskFileName = "c:\test2.rpt"
        CrExportOptions = myreport.ExportOptions

        With CrExportOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.CrystalReport
            .DestinationOptions = CrDiskFileDestinationOptions
            .FormatOptions = CrFormatTypeOptions
        End With


        Try
            '--- Export ---------------------------------------------
            ' Sets the current parameters and exports the report to
            ' specified format.
            '--------------------------------------------------------

            'Get the collection of parameters from the report
            crParameterFieldDefinitions = myreport.DataDefinition.ParameterFields

            'Access the specified parameter from the collection
            crParameterFieldDefinition = crParameterFieldDefinitions.Item("Dealer Number")

            'Get the current values from the parameter field. At this point there are zero values set.
            crParameterValues = crParameterFieldDefinition.CurrentValues

            'Set the current values for the numeric parameter field
            crParameterDiscreteValue = New ParameterDiscreteValue()
            crParameterDiscreteValue.Value = "80858"

            'Add the current value for the parameter field
            crParameterValues.Add(crParameterDiscreteValue)

            'The current parameter values must be applied for the parameter field.
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

            myreport.Export()
        Catch exc As CrystalDecisions.CrystalReports.Engine.InvalidArgumentException
            MsgBox(exc.Message)
        Catch exc As CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException
            MsgBox(exc.Message)
        Catch exc As CrystalDecisions.CrystalReports.Engine.LogOnException
            MsgBox(exc.Message)
        Catch exc As Exception
            MsgBox(exc.ToString())
        End Try

    End Sub

End Module
0
Comment
Question by:cwigley
  • 2
3 Comments
 

Author Comment

by:cwigley
ID: 10741456
I found that my problem was the fact I did not have an odbc setup on the machine I was running the code from. Please close this question.

 Thank you!
0
 
LVL 6

Accepted Solution

by:
KarunSK earned 500 total points
ID: 10744455
You need to post in the Community Support TA and ask for delete + refund, adding a link to this question.
0
 
LVL 6

Expert Comment

by:KarunSK
ID: 10930748
I am not sure why you accepted my comment as an answer. Did you post in the Community Support TA asking for a delete and refund? My comment should not be accepted as an answer since it was not intended to be one.

Cheers!
Karun.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy/Clone an object. 9 30
Help with distributing .NET Framework with Clickonce technology 2 30
Error on Add method 1 38
Server Error 11 47
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now