We help IT Professionals succeed at work.

crystal report in vc++

hemalisutaria
on
how to implement crystal report in VC++?
how to use ccrystalreportviewer class?
thanks for your interest in my query
Comment
Watch Question

AndyAinscowFreelance programmer / Consultant
SILVER EXPERT

Commented:
The example files supplied with Crystal reports should give you a very good starting point. (Speaking for versions 7 and 8, I don't know what the example files are like with ver. 8.5).

Also look on the crystal reports home page.  There you should find lots of code snippets for particular purposes.
Hi
There are two ways of doing it, One is u can insert activeX control
into ur project and use it. It will available in the
project->addToProject->Components and control menu item.

Here is the code to generate report.
CCrystalCtrl m_mycrystal; //in the header file of MyDlg.h

void MyDlg::OnButtonClick()
{
CString str1("Provider=MSDAORA.1;DSN =tas;UID =ABB_TAS_NT;PWD =ABBTASNT");
m_mycrystal.SetReportFileName("D:\\Ambar\\MyTest.RPT");  
m_mycrystal.SetConnect(str1);
}

Hope that helps u.
-shilpa
Commented:
Hi hemalisutaria,
I have had some interesting fun trying to get
the Crystal Reports Viewer control to work in my app
and it took quite some time, but now I have it running
quite smoothly.

If you check out the information in these links,
it should cover all the questions for the basic
setup and usage of the viewer control and
report manipulation for the CR Viewer.

Hope this gives you some help :)

Regards

D

http://support.crystaldecisions.com/communityCS/TechnicalPapers/scr_rdc_cpp.pdf

Commented:
How can preview the report on window and send it directly to printer without clicking print button?
AndyAinscowFreelance programmer / Consultant
SILVER EXPERT

Commented:
There is a function to print directly without previewing called PrintOut.
To preview it try the function ViewReport.

Commented:
I am using Crystal Active X Control. I didn't see any properties or methods like PrintOut and ViewReport.
I inserted a Crystal Active X Control on a Dialog box in MFC environment. I can use Print or PrinttoClient, PrintReport, SetDestination, SetAction.....
Report has to print directly to client's default printer and also report should be preview

thanks
AndyAinscowFreelance programmer / Consultant
SILVER EXPERT

Commented:
I've created a dlg and embedded the Crystal Reports viewer (which I believe is the ActiveX control) and in the dlg header class used
#import "craxdrt9.dll" no_namespace rename("FindText", "craxFindText")
This exposes the fn's I named before.  Maybe you are using a different way to get at the control.

Commented:
I created a member variable m_crystalreportcontrol and then added the report files as report source and passed the connection string dsn userid and password and selection formula after that i addred
m_CrystalReportCotrol.SetAction(1);
m_CrystalReportControl.PrintReport();
It gives me two preview windows. Then commented SetActon(1); then Report Preview is coming but it is not printing to default printer.

There is a method called m_CrystalReportControl.Print(CDC *pDC, DWORD dwFlags);
I don't how to use this method.

But If a Changed CrystalControlProperties -- Control -- Destination -- ToPrinter (instead of ToWindow), Report prints directly to Report's Default Printer (which printer i used at the time of designing the report), but I couldn't see the preview of report.

Report's Preview should come and prints automatically to default printer.

thanks

Commented:
What is the syntax for Connection String of Crystal Report Control for Native Oracle database????

I can run the report with same database which i created report against. If i changed the database name in script ie SetConnect then I am getting error "Can not open SQL Server". I am using Native Oracle dll.

Can any one help me???????

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: dpitman

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer

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