
Crystal Engine.LogOnException problems
Seems like I'm joining the many that have struggled with this problem. I'd
love to know why simple stuff like logging onto a database is made such a
cryptic problem to solve. And also why the documentation covering this area
is so ambiguous.
Here's my sample code. crRPT is a ReportDocument object.
Dim crLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo()
With crRPT
' Load the report
.Load("c:\Reports\MyReports.rpt", 1)
' Set the logon information
crLogonInfo = .Database.Tables(0).LogOnInfo
With crLogonInfo.ConnectionInfo
.ServerName = "MyServer"
.DatabaseName = "MyDB"
.UserID = "MyUID"
.Password = "MyPW"
End With
.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)
' Set the connection information for the table in the report.
crLogonInfo = .Database.Tables.Item(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = "MyServer"
crLogonInfo.ConnectionInfo.DatabaseName = "MyDB"
crLogonInfo.ConnectionInfo.UserID = "MyUID"
crLogonInfo.ConnectionInfo.Password = "MyPW"
crLogonInfo.TableName = "MyDB.dbo.Proc(MyStoredProcName;1)"
End With
I then go on to set some report parameters before calling the Export()
method to run the report into PDF format. Until I added the parameter info
it was opening the report just fine, but this is because the report wasn't
hitting the database while I wasn't providing parameter info.
Questions:
1. Which of the methods above should be used for logging on? Both?
2. What's the format of the TableName parameter of TableLogOnInfo object?
3. Would I be better off executing the stored proc into a dataset and
throwing the dataset at the report rather than getting the report to hit the
database?
It's driving me mad!!
Thanks in advance for your help.
Rob C-W