Solved

Active Data Report creation for ado recordset

Posted on 2001-07-26
4
1,142 Views
Last Modified: 2012-06-21
I'm wanting to pass an ado recordset to the crystal engine from vb6.

From an article at http://support.seagatesoftware.com/library/kbase/articles/c2002389.asp I shuld be able to do this with the vb code below. But an article at http://support.seagatesoftware.com/library/kbase/articles/c2002616.asp explains that to avoid an error the report must be an active data report which uses the active data driver.

My question is, how do you create an active data report?

I have tried File|New|Custom>>> which gives the 'DataFile' option, but it seems to require either an ado connection string or ODBC DSN, where as I want to define the report so that I can pass the rs at runtime.

There's also the dictionary option which i tried some time ago.


VB code:

Dim crpApplication As CRPEAuto.Application
Dim crpReport As CRPEAuto.Report
Dim crpDatabase As CRPEAuto.Database
Dim crpTables As CRPEAuto.DatabaseTables
Dim crpTable As CRPEAuto.DatabaseTable

Set crpApplication = CreateObject("crystal.crpe.application")
     
Set crpReport = crpApplication.OpenReport(App.Path & "\test.rpt")

Set crpDatabase = crpReport.Database
Set crpTables = crpDatabase.Tables
Set crpTable = crpTables.Item(1)

I then pass the report an ado recordset as follows:

Call crpTable.SetPrivateData(3, adoRS)
crpReport.Preview

0
Comment
Question by:rhubarbtwo
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 120 total points
ID: 6322392
rhubarbtwo

The key to what you are trying to do is the .TTX file (or data definition file).  This is an ASCII file which defines the structure and field names of the ADO recordset you will be passing to CRW.

Steps:
1.  Determine structure of the recordset in ADO
2.  Create the .TTX file (see below for option)
3.  Open designer and select More Data Sources->Active Data->Active Data (Field Defs Only) as your data source and browse to the .TTX file.  If you want, you can click the new button (optional) and use the simple Data Definition editor to create it.

4.  Define your report as usual - you can't do a meaningful preview though.

5. In VB, create your ADO recordset, let's call it rsTEST

6. Use something along the following lines to pass the recordset and preview your report.

dim crAppl as CRAXDRT.Application
dim crRep as CRAXDRT.Report
dim rs as ADODB.Recordset

' bunch of code to setup your recordset and load the data into it

set crAppl = new CRAXDRT.Application
set crRep = crAppl.OpenReport("C:\path\report.rpt")
' Set ADO recordset to first table in report
crRep.Database.Tables(1).SetDataSource rsTEST, 3
' Be sure to insert a CR Smart Viewer on form and then
crViewer1.ReportSource = crRep
crViewer1.ViewReport


Let me know if you need anything else.
DRRYAN3
0
 

Author Comment

by:rhubarbtwo
ID: 6326148
DRRYAN3: Sounds like you're the right person to talk to, thanks. I'm still setting this up, but in the meantime I'm wondering how this works with header/detail/footer data, I mean does the data have to be passed as one rs, so if it's a rs from a temporary table for each detail record it's header data will be repeated in the table, but because the fields are in the correct part of the report template when the single rs is passed the header/footer data will appear only once per set of detailed data, is that how it works?

0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6327586
I'm not sure I understand.

I have found that most of my reports can be boiled down into a single recordset of data pulled from a variety of related tables.  I do this with SQL/ADO in VB or with a view on SQL Server and base my report off that one dataset.  Using CRW Groups and sections you can then get that report laid out pretty much however you want.  Most of my reports don't even have an active detail section - it is suppressed, and all the real stuff goes into group footers.

It is possbile, according to seagate, to use more than one TTX when designing a report. I tried to get it working and couldn't in the time I had.
0
 

Author Comment

by:rhubarbtwo
ID: 6333465
I think one rs will be enough for me (I was confusing myself I think), but I was interested in your last para to your last comment though.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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

18 Experts available now in Live!

Get 1:1 Help Now