CR9 & VB6 & LogOnServer change UID & PWD at run time
Posted on 2003-11-03
I've got 234 Crystal Reports v.9 which I'm trying to get VB6 to batch run overnight using a specific UID and password for each report - during the day these reports are run ad-hoc by users (and the reports seem to remember the last user) - so I want to pass fresh UID and PWD for each report at run time using VB6 - there are several databases and database types being used although each report is limited to using one database
Having seen a previous thread I've just re-installed CR9 using custom installation and putting in EVERY driver it can give me so I don't think that's the problem.
I've been trying to use the LogOnServer method of the RDC (as recommended by Crystal Decisions) but to no avail (getting fault -2147189172) and the code I'm using is:
Dim App1 As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set App1 = CreateObject("CrystalRuntime.Application")
'XXX NEXT LINE IS WHERE IT ALWAYS FALLS OVER
App1.LogOnServer "p2smon.dll", "myDSNname", "myDatabase", "myname", "mypassword"
Set Report = App1.OpenReport("report.rpt")
CRViewer91.ReportSource = Report
Thanks for helping :-)