on 02-05-2011 4:19 AM
Error scenario:
The aplication is WindowsForms based
I have a crystal report with 4 subreports, by visual basic code I'm Setting Up the connection properties of the database and the parameters of the subreports.
In local mode my application works fine, but when used on a network fails with error CrystalDecisions.CrystalReports.Engine.LogOnException
Here is the code used
Dim crParameterDiscreteValue As CrystalDecisions.Shared.ParameterDiscreteValue
Dim crParameterFieldDefinitions As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
Dim crParameterFieldLocation As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
Dim oConexInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim crParameterValues As CrystalDecisions.Shared.ParameterValues
Dim cr_Reporte As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
oConexInfo.ConnectionInfo.ServerName = servername
oConexInfo.ConnectionInfo.DatabaseName = "theDatabase"
oConexInfo.ConnectionInfo.UserID = "user"
oConexInfo.ConnectionInfo.Password = "password"
cr_Reporte.Load(path_server & "rptFacturaCompra.rpt")
For x = 0 To cr_report.Database.Tables.Count - 1
cr_reporte.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
cr_reporte.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
Next
crParameterFieldDefinitions = cr_Reporte.DataDefinition.ParameterFields
For index = 0 To cr_Reporte.ReportDefinition.Sections.Count - 1
For intCounter = 0 To cr_Reporte.ReportDefinition.Sections(index).ReportObjects.Count - 1
With cr_Reporte.ReportDefinition.Sections(index)
If .ReportObjects(intCounter).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
mySubReportObject = CType(.ReportObjects(intCounter), crystalDecisions.CrystalReports.Engine.SubreportObject)
mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
crParameterFieldDefinitions = mySubRepDoc.DataDefinition.ParameterFields
crParameterFieldLocation = crParameterFieldDefinitions.Item(0)
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = TheParameterFilterValue
For x = 0 To cr_report.Database.Tables.Count - 1
mySubRepDoc.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
mySubRepDoc.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
Next
End If
End With
Next
Next
cr_Reporte.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4
cr_Reporte.PrintToPrinter(2, True, 1, 1)
Full Error data:
CrystalDecisions.CrystalReports.Engine.LogOnException:
Error en archivo C:DOCUME1ADMINI1CONFIG~1TempFacturaVenta {0D0348F4-954B-4BEA-BA77-AC070CE8D668}.rpt:
No se puede conectar: parámetros de conexión incorrectos. ---> System.Runtime.InteropServices.COMException (0x8004100F):
Error en archivo C:DOCUME1ADMINI1CONFIG~1TempFacturaVenta {0D0348F4-954B-4BEA-BA77-AC070CE8D668}.rpt:
No se puede conectar: parámetros de conexión incorrectos.
en CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetLastPageNumber(RequestContext pRequestContext)
en CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext)
Moved your post to .NET SDK forum
Curious why you are setting the log on info 2 times?
Also, use the subreportcontroller and set the log on info for each also.
Thank you
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Don
Here is my answer to your question.
Only provide the way to ensure that the connection is correct.
In the transcript of my code I found some errors
That's right.
....
For x = 0 To cr_reporte.Database.Tables.Count - 1
cr_reporte.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
cr_reporte.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
Next
.....
For x = 0 To mySubRepDoc.Database.Tables.Count - 1
mySubRepDoc.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
mySubRepDoc.Database.Tables(x).ApplyLogOnInfo(oConexInfo)
Next
now another question, the error may occur for a time out in the server's response?
Hello,
Sorry but I don't understand your reply? Are you saying you are connecting 2 times just to be sure it connects or are you saying you removed one line?
Then you say "now another question, the error may occur for a time out in the server's response?"
Is this something new now? If so please mark this as answered and post a new question.
If not then in debug mode add the TestConnection API and wait for a response. Or use a Try/Catch if it fails to connect then add a button to try again. It's not CR but your network or DB delaying the connection. Or it could be the connection failed in which case you need to manually add the log on info to verify it is correct.
Thank you
Don
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.