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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Crystal Reports with VB6 using the RDC component (Oracle 8) 2

Status
Not open for further replies.
Jan 8, 2001
163
US
I'm creating an automated report generator using Visual Basic 6. It uses Crystal Reports 8 to generate dynamic reports from an Oracle 8 database. I'm trying to do this with the new RDC component included in Crystal Reports 8. Has anyone used this? My problem is that whenever I launch the program I get an error that says the server isn't connected. I tried to correct the problem by referencing an ADO database object in the report but it gives me the same error.

Also, does anyone know of a good book that describes how all three of these (VB6,Oracle 8, and Crystal Reports 7) relate in plain english. I have (no joke) 7 books all of which explain a little of subject but nothing explains the relationship of all 3 together. The RDC component is especially troubling to integrate with Oracle. s-)
 
Does "dynamic" mean live data within user selected parameters or does it mean the user gets to design the report using the new report creation API?

Did you create an RPT with Crystal or did you create a DSR within the RDC environment?

How are you connnecting the report to the Oracle tables, via ODBC?


One problem is that the same report can't be changed from reading direct tables to reading a recordset. You can create the report to read Oracle directly, and then launch it from VB or you can have VB read the tables and pass the data to the report via recordset. However the same report can't do both.

Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Dynamic means that the user enters the parameter and a series of reports are then generated and stored for the user to access later.

I created the report in Crystal and then imported it into the DSR in the RDC environment using the "insert existing report" button.

I had created the report to read the Oracle database tables directly.

When I run vb application it seems that it can't the report can't access the database. Do I need to open the database in vb somehow before the CrystalReportViewer opens? I've been reading for days and I'm still a little cloudy on the relationship between Crystal Reports and Oracle when in a Visual Basic application environment.
 
As far as I know, launching from the VB environment in itself shouldn't affect the relationship between the report and Oracle.

The original report runs fine in the CR design environment?

The oracle connection, client software, dsn, odbc drivers, etc are all setup the same as they were in the CR design environment?

What is the text of the error message? Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
It only works if I have run the report in Crystal Reports and saved it with the data. When I don't do that it errors out with "Server Not Yet Opened".
 
It appears that I missed something. The RDC does need to open a connection to the server using either LogOnServer or SetLogOnInfo.

Check out the following article for a fairly clear description of when to use each command. You probably want LogOnServer.

Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Thanks. I'm much further than I was. Now I just need to figure out where to use the LogOnServer method.

Its "reportname.LogOnServer(dsn,servername,userid,password) correct? Does this go on the form load event for the form that contains the CRViewer or in the Initialize event of the RDC component. Any idea?
 
They are like this in V8 RDC:

report.database.LogOnServer ( pDllName , pServerName , [pDatabaseName], [pUserID], [pPassword] )

or

Report.Database.Tables (1).SetLogOnInfo ( pServerName ,[pDatabaseName], [pUserID], [pPassword] )

I have since heard that the second option (SetLoginInfo)is was more flexible. Each table can be different. If they are all the same, setting the first one will set it for all. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Okay here's my code for the form that calls the RDC component. I keep getting a compile error that says "expecting function or variable". It highlights the SetLogOnInfo of the code below. If I use the other method, LogOnServer, and comment out the SetLogOnInfo line, it errors out with the same error and hightlights the LogOnServer of the code. Can you see anythiing I haven't done correctly by chance?

Dim Report As New crptCMUsageReport
Dim intResult As Integer

Private Sub Form_Load()
Screen.MousePointer = vbHourglass
'intResult = Report.Database.LogOnServer("pdodbc.dll", "DATABEAST", "DATABEAST", "usernamehere", "pswdhere")
intResult = Report.Database.Tables(1).SetLogOnInfo("DATABEAST", "DATABEAST", "usernamehere", "pswdhere")
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub
 
Then I get two errors. A compile error saying "= expected" and then the same syntax error as before. I read something a while ago that said the SetLogOnInfo statement returns a value.
 
I think I got it mate! YEAH! Thanks. FYI - Buried deep in the depths of the KBase I found the syntax as follows:

Report.Database.Tables(1).SetLogOnInfo "DATABEAST", "DATABEAST", "usernamehere", "pswdhere"

No parentheses. Strange but I'll take it

Thanks again!!!
 
Glad I could help you stumble in the right direction. This one could certainly be documented better. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top