We help IT Professionals succeed at work.

binding recordset to crystal report

sheslop
sheslop asked
on
the following code doesn't bind the creted recordset to the crystal report, can someone please tell me why.

ReportPath = "//ftccr2\ftc_level2\DiffPressControl.rpt"
   
Set CRApp = CreateObject("crystalruntime.application")
Set CRReport = CRApp.OpenReport(ReportPath, 1)
   
SQLstr = "EXECUTE spDiffPressControl '23-Mar-2001', '1E'"
OpenConnection conn
OpenRecordSet Rs, SQLstr
CRReport.DiscardSavedData
CRReport.Database.SetDataSource Rs, 3, 1
   
CRReport.SelectPrinter PDriver, PName, "\\Zappa\hp 6p enh"
CRReport.PrintOut False, 1, False, 1, 1

Set Rs = Nothing
Set CRReport = Nothing
CRApp.CanClose
Comment
Watch Question

Valliappan ANSenior Tech Consultant
CERTIFIED EXPERT

Commented:
Is your report designed with the same struc. from stored procedure? I mean the recordset you pass, does it have the same structure as the one in report.

Just a thought.

Author

Commented:
it does, i don't get an error when i bind the recordset using "CRReport.Database.SetDataSource Rs, 3, 1".

is there a certain setting required in crystal report to allow binding?

on another note, using Print Engine calls. i use a discard saved data function, but then crystal couldn't connect to the SQL database to refresh the data. maybe the same is occuring above
Senior Tech Consultant
CERTIFIED EXPERT
Commented:
I am not sure, that this is your problem. Try using SetPrivateData. Look at CR help, with title "Using the Active Data Driver". It is given the steps to do this.

Give a try to it. Also look at these pages, could be useful to you:

http://support.crystaldecisions.com/kbase/c2000153.asp
(relating to your problem, in the other thread, with same title, that you posted).

http://support.crystaldecisions.com/kbase/c2004151.asp
(hope, relating to your current problem)
(Report Displays no Data or Sample Data from Data Definition File)

Cheers

Author

Commented:
thanks for your help valli_an, i discovered that having a stored procedure as the database link for the report, crystal required the parameters in the stored procedure to be set, and so binding a recordset wouldn't be effective.
Valliappan ANSenior Tech Consultant
CERTIFIED EXPERT

Commented:
sheslop,
you're welcome. I also learn something. Your problem solved is fine.

Cheers.

Author

Commented:
i thought i already accepted your comment as the answer? oh well ill just do it again
Valliappan ANSenior Tech Consultant
CERTIFIED EXPERT

Commented:
Thanks again. Did you use SetPrivateData or what?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.