How to use crystal report in VC6.0

zhaozj2021-02-16  60

Crystal report is a powerful tool for design and development, powerful, flexible, only a completely dynamically generated report in the Crystal Report CD, which is cumbersome. It is now a simple usage method in VC 6.0. Compilation Environment: VC 6.0 SP5, Windows 2000 Server SP3 (EN).

First, the dynamic link library used by the Crystal Report: According to the actual modified file path.

#import "C: / Documents and Settings / Administrator / Desktop / CRAXDRT9.DLL" NO_NAMESPACE

Second, define interface pointer variables

// Crystal Report Variable IapplicationPtr M_Application; IREPORTPTR M_REPORT; // Crystal Report Control Variables, add this control CcrystalReportViewer9 m_crViewer1 in the dialog box;

Third, specific implementation steps

// Instant M_ApplicationM_Application.createInstance (__UUIDOF (Application)); // Get M_Report Variables //staff.rpt is the report file established by wizard, the database uses SQL Server 7.0m_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 Variable // Database Server (local), database name STAFF, username SA, password SAM_REPORT-> Database -> Tables -> Item [1] -> setlogonInfo ("(local)", "staff", "sa", "sa"); / / Set Retrieve SQL Command M_Report-> Put_SQLQUERYSTRING (_BSTR_T) "SELECT *" ORDER BY ID "); // Does not display the repeating field m_report-> puteneselectdistInctRecords (TRUE); // Setting the search criteria, Retrieve the SQL command m_report-> putrecordselectionformula ((_BSTR_T) "{person.id} = '1'); // set the report author M_Report-> PutreportAuthor (" xiaojin "); // m_Report connection with the report controls m_CRViewer1.SetReportSource (m_Report); // display the report toolbar m_CRViewer1.SetDisplayToolbar (TRUE); // do not display the report left the grouping tree m_CRViewer1.SetDisplayGroupTree (FALSE); // do not show control borders m_CRViewer1.SetDisplayBorder (FALSE); // Refresh the data m_crviewer1.refresh (); // Displays the report content m_crViewer1.viewReport ();

In this way, the beautiful crystal report is displayed. The program exception handling part is omitted, please join.

转载请注明原文地址:https://www.9cbs.com/read-17460.html

New Post(0)