Solved

Link Crystal Report to a VB6 ADO recordset, run report from vb6

Posted on 2006-07-17
17
1,804 Views
Last Modified: 2008-01-09
I'd like to run some Crystal Reports directly from ADO recordsets in my VB6 application, but I don't know if it's possible, or the syntax to use. The data is in Oracle, and I use the recordsets in Grids on by VB forms. Thank you.
0
Comment
Question by:briankam
  • 6
  • 4
  • 3
  • +1
17 Comments
 
LVL 5

Expert Comment

by:dkDeveloper
ID: 17124591
Hi briankam,

Have you tried something like this...

crxReport.Database.SetDataSource [ADO_RECORDSET_VAR]


Cheers!
dK
0
 

Author Comment

by:briankam
ID: 17124899
I tried:       Form1.CrystalReport1.Database.SetDataSource [rsReport_Query],
where rsReport_Query is defined with:
Public rsReport_Query As ADODB.Recordset
Set rsReport_Query = New recordset
rsReport_Query.Open "Select ... From ...",
but the CrystalReport1 control doesn't have a .Database property (to program errored to "Object doesn't support this property or method").
I'm trying to run the report with the command:
Form1.CrystalReport1.Action = 1
which displays Crystal in its own window, not a report viewer window (on a form). Thank you.

0
 
LVL 5

Expert Comment

by:dkDeveloper
ID: 17124930
Hi dkDeveloper,

What version of CR are you using?

dK
0
 

Author Comment

by:briankam
ID: 17125105
Let me clarify:
In looking at older code, I see that I did just what you suggested, and it worked if I viewed the report in a Crystal Report Viewer Window on a VB6 form, using:
Dim Report As CRAXDRT.Report
Set Report = crystal.OpenReport("C:\appdir\...\Report_A.rpt")
Report.Database.SetDataSource rsReport_Query
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

But I had no luck exporting data from in that scenario. So I'm trying to set the report's data source with the Crystal Report control (CrystalReport1) to the ADO recordset, and then call it with:
Me.CrystalReport1.ReportFileName = "C:\appdir\...\ReportA.rpt"
Me.CrystalReport1.Action = 1

but I don't see such a property on the Crystal Report Control.
Thanks again,
0
 
LVL 5

Expert Comment

by:dkDeveloper
ID: 17125323
Hi briankam,

Stabbing in the dark again here but what about this...

Dim Report As CRAXDRT.Report
Set Report = crystal.OpenReport("C:\appdir\...\Report_A.rpt")
Report.Database.SetDataSource rsReport_Query
CRViewer1.ReportSource = Report
Me.CrystalReport1.Action = 1

Good Luck!
dK
0
 

Author Comment

by:briankam
ID: 17125561
Thanks dK,

I'm using CR v. 8.5 with VB6.

How should I define the 'crystal' you use in the 2nd line? When I initialized crystal with:

Public crystal As CRAXDRT.Application

I got an error on the set report = crystal.OpenReport("C:\...\Report_A.rpt"): Method or data member not found.

Thanks again,
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17126944
Are you using the RDC or the OCX?

The suggestions being made are for use with the RDC (CRAXDRT.DLL)

Your code seems to be for the OCX (crystl32.ocx)

I suggest you remove the OCX references and add the Crystal references and the Crystal RDC Viewer.

The OCX was dropped in CR9 and later versions so if you plan to upgrade in the future you will have to change your method.

mlmcc
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:briankam
ID: 17129249
Thanks mlmcc,

I need to look into the things you mention, as I'm not familiar yet with them.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 17134580
Here is a link to help migrate from the OCX to the RDC
http://support.businessobjects.com/communityCS/TechnicalPapers/scr8-ocxtordc.pdf.asp

mlmcc
0
 
LVL 6

Expert Comment

by:AHMKC1
ID: 17137224
if you use Crystal Report control, create a report from CR then try

CrystalReport1.ReportFileName=Your report File Path
CrystalReport1.Action=1

if you use Crystal Report Viewer control i.e. OCX then

Design a report in your vb CR Designer and then try it
place a report veiwer control on form and write following code at load events

Dim Rpt As Report
Dim Rs As Recordset

Set Rs = New Recordset
Set Rpt = New ReportName
Rs.Open "SELECT * FROM TableName", Cnn, adOpenStatic, adLockOptimistic   ***** Where cnn is your Connection String
Rpt.Database.SetDataSource Rs, 3, 1

CRViewer1.ReportSource = Rpt
CRViewer1.ViewReport
CRViewer1.Zoom (100)
0
 

Author Comment

by:briankam
ID: 17137822
Thanks AHMKC1,

I have actually done both of the methods you mentioned. My final goal is to assign my ADO recordset as the source of the RDC report -- the first method you show (which will enable me to put all my filter logic in the VB code that generates the recordset). Thanks for any further help you can give.
0
 
LVL 6

Expert Comment

by:AHMKC1
ID: 17138071
for filtering your data use Report Parameter

Create parameter in your report file on basis of your filtered field  (like  paramID)

Then on your form write follwing code

CrystalReport1.ReportFileName=Your report File Path
CrystalReport1.ParameterField(0)="ParamID;"& textID.Text & ";True"
CrystalReport1.Action=1

thanks
0
 

Author Comment

by:briankam
ID: 17496937
Thanks mlmcc, and I'm sorry I let the question lapse. What happened was that I upgraded to Crystal version 11, and I can set the ADO recordset as the datasource with: "      CrystalReport.Database.SetDataSource rsReport_Query", and can export while viewing in report viewer. So the solution was to upgrade.

All the comments were helpful though, to lead me there, but there wasn't a definitive solution.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17499339
If a particular comment was helpful you can accept it with a B grade.  That is essentially what B means.  The comment led you to the solution.

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 17507539
Glad i could help

mlmcc
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now