cwigley
asked on
CrystalDecisions.CrystalReports.Engine.LogOnException: Logon Failed
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.CrystalRe ports.Engi ne.LogOnEx ception:Lo gon Failed
CODE:
Imports CrystalDecisions.CrystalRe ports.Engi ne
Imports CrystalDecisions.Shared
Module Module1
Private myreport As CrystalDecisions.CrystalRe ports.Engi ne.ReportD ocument
Sub Main()
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinition s As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
myreport = New CrystalDecisions.CrystalRe ports.Engi ne.ReportD ocument()
myreport.Load("c:\test1.rp t", OpenReportMethod.OpenRepor tByTempCop y)
Dim tbCurrent As CrystalDecisions.CrystalRe ports.Engi ne.Table
Dim tliCurrent As CrystalDecisions.Shared.Ta bleLogOnIn fo
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(t liCurrent)
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 CrDiskFileDestinationOptio ns As New DiskFileDestinationOptions ()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptio ns.DiskFil eName = "c:\test2.rpt"
CrExportOptions = myreport.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.Disk File
.ExportFormatType = ExportFormatType.CrystalRe port
.DestinationOptions = CrDiskFileDestinationOptio ns
.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
crParameterFieldDefinition s = myreport.DataDefinition.Pa rameterFie lds
'Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinition s.Item("De aler Number")
'Get the current values from the parameter field. At this point there are zero values set.
crParameterValues = crParameterFieldDefinition .CurrentVa lues
'Set the current values for the numeric parameter field
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.V alue = "80858"
'Add the current value for the parameter field
crParameterValues.Add(crPa rameterDis creteValue )
'The current parameter values must be applied for the parameter field.
crParameterFieldDefinition .ApplyCurr entValues( crParamete rValues)
myreport.Export()
Catch exc As CrystalDecisions.CrystalRe ports.Engi ne.Invalid ArgumentEx ception
MsgBox(exc.Message)
Catch exc As CrystalDecisions.CrystalRe ports.Engi ne.Paramet erFieldCur rentValueE xception
MsgBox(exc.Message)
Catch exc As CrystalDecisions.CrystalRe ports.Engi ne.LogOnEx ception
MsgBox(exc.Message)
Catch exc As Exception
MsgBox(exc.ToString())
End Try
End Sub
End Module
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.CrystalRe
CODE:
Imports CrystalDecisions.CrystalRe
Imports CrystalDecisions.Shared
Module Module1
Private myreport As CrystalDecisions.CrystalRe
Sub Main()
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinition
Dim crParameterFieldDefinition
myreport = New CrystalDecisions.CrystalRe
myreport.Load("c:\test1.rp
Dim tbCurrent As CrystalDecisions.CrystalRe
Dim tliCurrent As CrystalDecisions.Shared.Ta
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(t
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 CrDiskFileDestinationOptio
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptio
CrExportOptions = myreport.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.Disk
.ExportFormatType = ExportFormatType.CrystalRe
.DestinationOptions = CrDiskFileDestinationOptio
.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
crParameterFieldDefinition
'Access the specified parameter from the collection
crParameterFieldDefinition
'Get the current values from the parameter field. At this point there are zero values set.
crParameterValues = crParameterFieldDefinition
'Set the current values for the numeric parameter field
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.V
'Add the current value for the parameter field
crParameterValues.Add(crPa
'The current parameter values must be applied for the parameter field.
crParameterFieldDefinition
myreport.Export()
Catch exc As CrystalDecisions.CrystalRe
MsgBox(exc.Message)
Catch exc As CrystalDecisions.CrystalRe
MsgBox(exc.Message)
Catch exc As CrystalDecisions.CrystalRe
MsgBox(exc.Message)
Catch exc As Exception
MsgBox(exc.ToString())
End Try
End Sub
End Module
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
Cheers!
Karun.
ASKER
Thank you!