The simple use method of Crystal report in vc++6.0

Source: Internet
Author: User

Crystal Report is a report design and development of a powerful tool, powerful, flexible design, in the Crystal Report CD-ROM only provides a fully dynamic example of the report, the use of cumbersome. This paper introduces its simple use method in vc++6.0. Compilation environment: vc++6.0 SP5, Windows Server sp3 (en). One, the import Crystal Report uses the dynamic join library: According to the actual modification file path.

#import "C:\Documents and Settings\Administrator\桌面\cr\craxdrt9.dll" no_namespace

Second, define interface pointer variables

//水晶报表变量
IApplicationPtr m_Application;
   IReportPtr m_Report;
//水晶报表控件变量,在对话框中加入该控件
   CCrystalReportViewer9  m_CRViewer1;

Third, the concrete realization step

Instantiation of M_application
M_application.createinstance (__uuidof (application));
Get M_report variable
Staff.rpt for a report file created with a wizard, the database uses SQL Server 7.0
M_report =m_application->openreport ("C:\\Documents and settings\\administrator\\ Desktop \\cr\\debug\\staff.rpt");
Set report title
M_report->put_reporttitle (_bstr_t ("Title"));
Setting Database connection variables
Database server (local), database name staff, user name SA, password SA
M_report->database->tables->item [1]->setlogoninfo ("(local)", "Staff", "sa", "sa");
To set the Retrieve SQL command
M_report->put_sqlquerystring ((_bstr_t) "SELECT * from person where id< ' 4 ' ORDER by id");
Do not show duplicate fields
M_report->putenableselectdistinctrecords (TRUE);
Set search criteria, use Crystal Report syntax, function with settings retrieve SQL command
M_report->putrecordselectionformula ((_bstr_t) "{person.id}= ' 1");
Set report author
M_report->putreportauthor ("Xiaojin");
Connecting M_report to report controls
M_crviewer1.setreportsource (M_report);
Show Report Tool bar
M_crviewer1.setdisplaytoolbar (TRUE);
Do not display the grouping tree to the left of the report
M_crviewer1.setdisplaygrouptree (FALSE);
Do not display control borders
M_crviewer1.setdisplayborder (FALSE);
Refreshing data
M_crviewer1.refresh ();
Show report Content
M_crviewer1.viewreport ();

In this way, the beautiful Crystal Report is displayed. Exception processing part of the program omitted, please join.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.