
Desperately Need HELP!!!!-Crystal Report-Logon Fail - Can anyone even give me a lead
If I don't include a change to the formula in my code below,
i.e, instead of this
oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula + "' and
{RECORDS.CONSTITUENT_ID}= '" & "'" & sConstitID & "'" 'existing formula +
if I do this :
oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula
the code works, but if I include the change to the formula I get the logon
failed error. I have two different reports, one works and the other does
not. I do not see what the difference is between the two. I believe there
must be some difference, but I can't see it. HELP!!!!!!!!
Here I go again. If you know where I can post this and get some help, let
me know.
The code below works for one report, but for another report I get an Error
5 - Logon Failed
Private Sub CreateReport(ByVal sReport, ByVal sPDF, ByVal sConstitID, ByVal
sRptType)
' passes report location i.e c:\inetpub\wwwroot\report.rpt
' report custom formula i.e {Table.Field1}>1200
' displays report in browser (temp.pdf)
Dim exportOpts As New ExportOptions()
Dim oRpt As New ReportDocument()
Dim conTest As Boolean
Dim diskOpts As New DiskFileDestinationOptions()
Dim strFormula As String
'load report
oRpt.Load(sReport)
'log on to SQL server
Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = "server"
crLogonInfo.ConnectionInfo.DatabaseName = "Db"
crLogonInfo.ConnectionInfo.UserID = "ODBCname"
crLogonInfo.ConnectionInfo.Password = "pswd"
oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)
'export report to viewer PDF
exportOpts = oRpt.ExportOptions
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat '
ExportFormatType.WordForWindows, ExportFormatType.Excel other formats
'temp file name
diskOpts.DiskFileName = sPDF
exportOpts.DestinationOptions = diskOpts
oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula + "' and
{RECORDS.CONSTITUENT_ID}= '" & "'" & sConstitID & "'" 'existing formula +
custom
On Error GoTo Errcode
oRpt.Export()
If gRptErr = "" Then
oRpt.Close()
End If
End Sub
After my oRpt.export statement the problem errors with the Error 5. If I
change this statement to
oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula
and I don't include the formula that I'm trying to append the report works
as well.
I don't understand why this is, I use the very same code with another
report. They are very similar. It should work.
Any ideas or ideas about who I can ask.
Please help me. I have to get this done today.
Thank you,
Wilson Bell