Usage of Crystal Reports in vc6.0

Source: Internet
Author: User

Usage of Crystal Reports in vc6.0
 
Author: [fengyunshuang Jue]

1. Import the dynamic link library used by the crystal Report: Modify the file path according to the actual situation.
# Import "D: // crcraxdrt9.dll" no_namespace

Ii. Define interface pointer Variables

// Crystal report variable

Iapplicationptr m_application;

Ireportptr m_report;

// Crystal report control variable. Add the control to the dialog box.

Ccrystalreportviewer9 m_crviewer1;

Iii. Implementation steps

// Instantiate m_application

M_application.createinstance (_ uuidof (Application ));

// Obtain the m_report variable

// Staff. rpt is a report file created through the Wizard. The database uses SQL Server 7.0

M_report = m_application-> openreport ("C: documents and settingsadministrator desktop crdebustaff. rpt ");

// Set the report title

M_report-> put_reporttitle (_ bstr_t ("title "));

// Set 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 ");

// Set the search SQL command

M_report-> put_sqlquerystring (_ bstr_t) "select * From person where ID <'4' order by ID ");

// Do not display duplicate fields

M_report-> putenableselectdistinctrecords (true );

// Set the search conditions and use the crystal report syntax. The function is the same as setting the search SQL command.

M_report-> putrecordselectionformula (_ bstr_t) "{person. ID} = '1 '");

// Set report author

M_report-> putreportauthor ("Xiaojin ");

// Connect m_report to the report Control

M_crviewer1.setreportsource (m_report );

// Display the report Toolbar

M_crviewer1.setdisplaytoolbar (true );

// The group tree on the left of the report is not displayed.

M_crviewer1.setdisplaygrouptree (false );

// Do not display the widget border

M_crviewer1.setdisplayborder (false );

// Refresh data

M_crviewer1.refresh ();

// Display the Report Content

M_crviewer1.viewreport ();

In this way, the beautiful crystal report is displayed. The exception handling part of the program is omitted. Please add it on your own.
 
 

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.