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

ADO, Crystal Reports 7

Status
Not open for further replies.

georgec

Programmer
Joined
Jan 28, 2002
Messages
4
Location
US
I noticed there are some great tips on here. But most of the ado - crystal reports examples show the following code.

Dim mcstrConnect As ADODB.Connection
dim rs as ADODB.Recordset
Dim Report As New CrystalReport1
Dim strSql As String
Dim strCnn As String

Report.Database.Tables(1).SetLogOnInfo "SEIMS", "ProdTraining", txtUser, txtPass

Set mcstrConnect = New ADODB.Connection
mcstrConnect.Open "Provider=SQEDB.1;Persist Security Info=True;Initial Catalog=ProdTraining;Data Source=SEIMS", txtUser, txtPass
strSql = "Select * from SignUpSheet"
rs.Open strSql, mcstrConnect
Report.Database.SetDataSource rs
CRViewer1.ReportSource = Report

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

With the name of the report being "Report"
When I type Report.Database in VB IDE. I dont get the .Database part.

Do I have crystal installed correctly? I have tried dropping the crystal ocx on my form. I have tried referencing the ocx. I assume

Dim Report As New CrystalReport1

refers to a crystal ocx object dropped onto the form. I am using VB 6.0 with sp4 and crystal reports professional 7.0. I dont see CrystalReport1 in intellisense either. What am I doint wrong?

I do get the following instead:

dim rpt As Crystal.CrystalReport
set rpt = new Crystal.CrystalReport

Thanks in advance for your help
 
This code is for the RDC technology. Use the RDC, not the OCX. The OCX has not been further developed since V6.

Dim X as CrystalReport1

...means that you have a report inside of your VB project called CrystalReport1. Not an external .rpt file.
 
I am not familiar with the RDC. Does that stand for remote data control? I dont want to bind a data control to the crystal report. Is this my only option for ado records sets?

Thanks for your help balves.
 
RDC = Report Designer Control

It has nothing to do with VB data controls.

You cannot use the OCX and pass an ADO recordset to the report. You need to use code similar to your original posting. Don't drop an OCX control on the VB form.

You can either create the report in a separate .rpt file and open it in VB, passing the ADO recordset, or create the report as a .DSR file inside of the VB project. In your example, the report has been created inside of the VB project.

If you create the .DSR file and call it CrystalReport1 inside of VB, then you can do a

Dim Report as CrystalReport1

You do this in VB by right-clicking in the Project window and choosing the menu item "Add" and then the sub-menu item "Crystal Report".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top