Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 9 & VB6 & LogOnServer method

Status
Not open for further replies.

jocerakower

Programmer
Apr 29, 2003
1
GB
jocerakower (Programmer) Nov 3, 2003
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 used ad-hoc by users (and 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 being used although each report is limited to using one database

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:

Sub Form_Load()

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")
Report.DiscardSavedData

Debug.Print App1.GetVersion
Report.Database.Verify
CRViewer91.ReportSource = Report
CRViewer91.ViewReport

Thanks for helping :)


 
First of all I would suggest putting
>Set Report = App1.OpenReport("report.rpt")
before you set the logon server.

If it does not work . . . the following code works in my app, but Crystal 8 - might work for you . . .

Set CrxApp = New CRAXDRT.Application
Set CrxRpt = CrxApp.OpenReport(ReportName)

CrxRpt.RecordSelectionFormula = ""

CrxRpt.Database.Tables(1).SetLogOnInfo ServerName, DBName, LogonUser, LogonPassword
CrxRpt.Database.Tables(1).Location = TableName

CrxRpt.PrinterSetup (0)
crvRPTView.ReportSource = CrxRpt

The following site has a good example to LINK a REPORT TO a RECORDSET (Crystal 9 & VB 6 )


Hope you find this useful!
[flowerface]

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top